working with arrays part two

Problem

You want to create an array, then traverse it.



Solution

Following up from part one – working with arrays.

To spin through all elements in our names array, here is the code below.



Example


<?php

$count=count($names);
for ($i=0;$i<$count;$i++) { print($names[$i]."n"); }

?>

Then for our string index array (hash):

<?php

while(list($k,$v)=each($addresses)) {
echo "$k lives at $vn";
}

?>



Reference

[tags]PHP Arrays, PHP Hashes, PHP Coding School[/tags]



Leave a Reply

Your email address will not be published. Required fields are marked *