Reputation: 13
I'm iterating li tag using for loop inside ol tag but the ordered list numbers for li tag are not displayed
Here is my code:
<ol style="word-wrap:break-word;">
<?php
for ($i = 0; $i < $length; $i++) {
echo '<li style="margin-left:0px;">'.$TnC1[$i].'</li>';
}
?>
</ol>
This is the result:
Upvotes: 1
Views: 543
Reputation: 2857
You can try out following code snippet.
<ol style="word-wrap:break-word;">
<?php
//Start the counter value from 1 instead of 0
for ($i = 1; $i <= $length; $i++)
{
//Print the counter value
echo $i.".".$TnC1[$i];
}
?>
</ol>
Upvotes: 1
Reputation: 4739
Remove the unwanted ,(comma) in for loop and also put closing tag ''.
echo '<ol style="word-wrap:break-word;">';
for ($i = 0; $i < $length; $i++) {
echo '<li style="margin-left:0px;">'.$TnC1[$i].'</li>';
}
echo '</ol>'
Upvotes: 2