using functions to create a set of variables php -
i trying create function create set of variables arrays so
function breakdownpostarray($count, $fields) { $repeat = 1; $num = 0; while ($repeat <= $count) { $a = "array" . $repeat; $$a = array_slice($_post, $num, $fields); $repeat ++; $num += 4; } i want able use these variables outside of function. stands declaring variables outside function , pulling them in globally feels defeating object , repeating myself much.
is there better way achive want out declearing variables outside function?
assuming you've got valid reason accomplish you're looking for...
change
$a = "array" . $repeat; $$a = array_slice($_post, $num, $fields); to
$globals["array" . $repeat] = array_slice($_post, $num, $fields); ... feels me convoluted design, can't see enough of code certain.
Comments
Post a Comment