![]() |
Learning syntax foreach ($client as $k=>$v) { } - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Learning syntax foreach ($client as $k=>$v) { } (/showthread.php?tid=10122) |
Learning syntax foreach ($client as $k=>$v) { } - El Forum - 07-19-2008 [eluser]Unknown[/eluser] foreach ($client as $k=>$v) { } $client is an array now $k => $v ??? Learning syntax foreach ($client as $k=>$v) { } - El Forum - 07-19-2008 [eluser]Colin Williams[/eluser] PHP has a User Guide too: http://us3.php.net/foreach Learning syntax foreach ($client as $k=>$v) { } - El Forum - 07-20-2008 [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? Learning syntax foreach ($client as $k=>$v) { } - El Forum - 07-20-2008 [eluser]Yash[/eluser] yup.. that helps me. Thank you |