![]() |
New to php Array question, probably VERY simple... - 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: New to php Array question, probably VERY simple... (/showthread.php?tid=20016) |
New to php Array question, probably VERY simple... - El Forum - 06-25-2009 [eluser]PoetaWD[/eluser] Sorry for this very infant question.. I am just learning PHP. I am using the form helper to create a <select> input... The data is passed to the view file as a object... But i am having trouble building the array to generate the <select> input ! Here is what I got: Code: foreach ($clientes as $cliente) But that will generate a array like this: $opcoesC[0] = 'aaaaaaaaa' => 'aaaaaaaaaaa' $opcoesC[1] = 'bbbbbbbbb' => 'bbbbbbbbbbb' ... or like this: Array ( [0] => Array ( [7] => 7 - jkkk ) [1] => Array ( [8] => 8 - jk ) [2] => Array ( [9] => 9 - kkh ) [3] => Array ( [10] => 10 - klçklçklç ) ) I needed to be generated like this: $opcoesC = array( 'aaaaaaa' => 'aaaaaaa','bbbbbbb' => 'bbbbbbbb','cccccccc'=>'ccccccc' ....); I have also tryed this: Code: $opcoes = array( Can anyone give me a hint ? Thanks in advance... New to php Array question, probably VERY simple... - El Forum - 06-25-2009 [eluser]kgill[/eluser] The reason you're getting: Code: $opcoesC[0] = ‘aaaaaaaaa’ => ‘aaaaaaaaaaa’ Code: $opcoesC[] = array($cli... Code: $opcoesC[$cliente->id] = $cliente->id.' - '.$cliente->stNome; New to php Array question, probably VERY simple... - El Forum - 06-25-2009 [eluser]Phil Sturgeon[/eluser] Here's what kgill said implemented to your example. Code: foreach ($clientes as $cliente) New to php Array question, probably VERY simple... - El Forum - 06-25-2009 [eluser]PoetaWD[/eluser] [quote author="Phil Sturgeon" date="1245961469"]Here's what kgill said implemented to your example. Code: foreach ($clientes as $cliente) Got that ! Thank you very much for the quick help ! It is working now ! ![]() New to php Array question, probably VERY simple... - El Forum - 07-29-2009 [eluser]tashigiri[/eluser] [quote author="Phil Sturgeon" date="1245961469"]Here's what kgill said implemented to your example. Code: foreach ($clientes as $cliente) Thanks Phil and kgill.. my problem solved..^^ |