Saturday, 15 August 2015

php - How to perform a count in a loop -



php - How to perform a count in a loop -

foreach ($arrquestionid $key=>$question) { ?> <div class='lt-container'> <p><strong>question <span id="quesnum"></span>:</strong></p> </div> <?php } ?>

in code above have while loop displays question :. want in between question , : want include count number every time question appears, contains count number next below:

question 1: question 2: question 3: ...

how can done?

create variable , increment in foreach.

like:

$s = 1; foreach($value $text) { echo "question #".$s." :".$text; $s++; }

php html

No comments:

Post a Comment