Welcome Guest, Not a member yet? Register   Sign In
New to php Array question, probably VERY simple...
#1

[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)
                                {
                                    $opcoesC[] = array($cliente->id => $cliente->id.' - '.$cliente->stNome);
                                }
echo form_dropdown('cliente', $opcoesC);

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(
                        '' => 'Selecione o funcionário',
               foreach ($funcionarios as $funcionario)
                                {
           $funcionario->id => $funcionario->id.' - '.$funcionario->stNome,
                     }
                            );

Can anyone give me a hint ?

Thanks in advance...


Messages In This Thread
New to php Array question, probably VERY simple... - by El Forum - 06-25-2009, 08:09 AM
New to php Array question, probably VERY simple... - by El Forum - 06-25-2009, 08:39 AM
New to php Array question, probably VERY simple... - by El Forum - 06-25-2009, 09:24 AM
New to php Array question, probably VERY simple... - by El Forum - 06-25-2009, 10:08 AM
New to php Array question, probably VERY simple... - by El Forum - 07-29-2009, 10:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB