Q:

How to perform a count in a loop

foreach ($arrQuestionId as $key=>$question) {

?>

<div class='lt-container'>
<p><strong>QUESTION <span id="quesnum"></span>:</strong></p>
</div>

<?php

}

?>

In code above I have a while loop where it displays QUESTION :. Now what I want to do is in between QUESTION and : I want to include a count number so that for every time QUESTION appears, it contains a count number next to it as like below:
QUESTION 1:

QUESTION 2:

QUESTION 3:

...

How can this be done?

A:

Create a variable and increment it in foreach.
Like:
$s = 1;
foreach($value as $text) {
echo "Question #".$s." :".$text;
$s++;
}

