PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
$fruits = array("Apple" => "Red", "Mango" => "Green", "Lemon" => "Yellow", "Durian" => "Green");
$fruitsї"Dragon Fruit"] = "Pink";
reset($fruits);
while (list ($key, $value) = each($fruits)) {
echo "Color of $key is $value <br>";
echo "Color of " . key($fruits) . " is " . current($fruits) . "<br>";
}
And the result is :
Color of Apple is Red
Color of Mango is Green
Color of Mango is Green
Color of Lemon is Yellow
Color of Lemon is Yellow
Color of Durian is Green
Color of Durian is Green
Color of Dragon Fruit is Pink
Color of Dragon Fruit is Pink
Color of is
Don't you think this is strange?
The rest of it outside the code
are just html tags.
Thanks,
Andrew
Last edited by andrewt on Sat Aug 09, 2003 11:08 am, edited 1 time in total.
Pootergeist, he says that's the only code, aside from some html
Andrewt, that code has a few deprecated elements to it. You may or may not know this, but your problem code can be rewritten to be a lot simpler and cleaner; observe:
However, I am only writting the code as to see the result of the code.
Just trying to find an explanation to the code, as I understanding it
it should be two pairs of the same data appear one after the other
on a new line.
Color of Apple is Red
Color of Apple is Red
Color of Mango is Green
Color of Mango is Green
Color of Lemon is Yellow
Color of Lemon is Yellow
Color of Durian is Green
Color of Durian is Green
Color of Dragon Fruit is Pink
Color of Dragon Fruit is Pink