Welcome Guest, Not a member yet? Register   Sign In
Learning syntax foreach ($client as $k=>$v) { }
#3

[eluser]thinkigniter[/eluser]
Let my shine some light on this.
I found it confusing too.

[quote author="a123bcd" date="1216475407"]foreach ($client as $k=>$v) { }
$client is an array

now $k => $v ???[/quote]

$k == $key == $ID
$v == $value == $NAME

This is your array( '1' => 'some_name' , '2' => 'some_other_name' );



foreach ($client as $ID => $NAME)
{

echo '<p>client ID is: '. $ID . </p>;
echo '<p>client Name is: '. $NAME . </p>;
echo '<br />';

}
results in...
client ID is: 1
client Name is: some_name

client ID is: 2
client Name is: some_other_name

Does this help?


Messages In This Thread
Learning syntax foreach ($client as $k=>$v) { } - by El Forum - 07-19-2008, 02:50 AM
Learning syntax foreach ($client as $k=>$v) { } - by El Forum - 07-19-2008, 04:10 AM
Learning syntax foreach ($client as $k=>$v) { } - by El Forum - 07-20-2008, 12:44 AM
Learning syntax foreach ($client as $k=>$v) { } - by El Forum - 07-20-2008, 09:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB