Tuesday, 20 August 2013

do - while with $var[x]

do - while with $var[x]

i'm still in the learning curve with php
I'm trying to achieve this:
let's say i have an ul with dynamically generated li's. And these li's
must be populated with data stored in a variable. For example:
$var[0] = 'first data';
$var[1] = 'second data';
$var[2] = 'third data';
result:
<ul>
<li>first data</li>
<li>second data</li>
<li>third data</li>
</ul>
I know i must put something like this:
<ul>
<?php do { ?>
<li><?php echo $var ?></li>
<?php } while (condition); ?>
</ul>
But, i didn't figure which is the correct condition syntax, and how to
create the variable which puts the differents items into the li's (the
$var item into the li).

No comments:

Post a Comment