3
I would like to create a array dynamically, I tried this way:
$zt = array();
$zt = ($p_p[0] => $_p_p[1]);
print_r($zt);
$p_p
is a array, where index 0 is the name, and index 1 is the value, 2 name, 3 value..
$p_p
is configured like this, but unfortunately gives error in line $zt
:
Parse error: syntax error, Unexpected '=>'
If I do so:
$zt = ($p_p[0]);
no mistake, but the index is "0", I needed it was in fact the name, since I will pass this array $zt
for POST
as if they were fields of a form.
Look, I found the solution, but I didn’t find it logical. I declared as array $zt, like this:
$zt = array();
, then I hoped that what $zt gets behaves like array, but I needed to change for that:array($p_p[0] => $_p_p[1]);
, that is, I informed that it was array(again) what I put inside.– Ale
You had to declare again that the
$zt
is an array because you are overwriting the variable$zt
.– Oeslei
perfect! thanks
– Ale