Lesson 8: How to find the size of an array
4 posts Page 1 of 1
Lesson 8: How to find the size of an array
In lesson 8, there is a suggestion of using the following code:<?php
foreach ($arrFruits as $x){
echo $x
}
?>
I have uploaded it using the $fruitlist example, trying to merge the above code with the <ul> <li></il></ul> but the list appears that the fruit items are not align with the bullets. I wonder what is wrong with the position or other reasons that caused it. My link is as follows:
http://saowai.netne.net/arrays-loop-foreach.php
Re: Lesson 8: How to find the size of an array
i think it's a bad example in lesson 8you can get the size of array by using this method
- Code: Select all
<?php
$fruits = array("apple","orange","mango");
echo count($fruits);
?>
And if you want to combine the foreach with ul and li you can do it like this
- Code: Select all
<?php
$fruits = array("apple","orange","mango");
echo '<ul>';
foreach ($fruits as $x) {
echo '<li>'.$x.'</li>';
}
echo '</ul>';
?>
Re: Lesson 8: How to find the size of an array
Very Good ! I wonder why the tutorial gave us bad examples. I tried both suggestions. The count of fruits and ul.li and ol.li, all of them work perfectly. Thanks a lot ! It makes me feel more like to learn building website because of these forums.Re: Lesson 8: How to find the size of an array
Dolce Good luck for further learningPage 1 of 1