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

[eluser]Unknown[/eluser]
foreach ($client as $k=>$v) { }
$client is an array

now $k => $v ???
#2

[eluser]Colin Williams[/eluser]
PHP has a User Guide too: http://us3.php.net/foreach
#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?
#4

[eluser]Yash[/eluser]
yup.. that helps me.

Thank you




Theme © iAndrew 2016 - Forum software by © MyBB