arrays - Issue with using extract() PHP -
i have dynamically created array , want extract array , put each item own variable.
here's php:
$bar = $_post['foo']; extract($bar); echo $1;
foo array form made.
whenever run script error:
parse error: syntax error, unexpected '1' (t_lnumber), expecting variable (t_variable) or '$' in /application/...
when change code to:
$bar = $_post['foo']; extract($bar, extr_prefix_all, "bar_"); echo $bar_1;
i undefined variable error.
please me.
update:
my first code informational, person might come across question problem not knowing what's wrong. second piece of code actual code.
m intention input each array item different field in mysql table. haven't written full code yet since extract() thing doesn't seem working.
update 2:
$_post['foo'] array of checkbox values
variables in php cannot start numbers:
echo $1;
that's invalid , throw error.
you're using extract improperly in you're using on may or may not array. have no guarantee $_post['foo'] associative array(and it's not), array type extract works on. extract uses keys associative array create new variables.
Comments
Post a Comment