php - is there anything like implode for arrays of arrays? -
i understand implode works this:
$array = array('value', 'value2'); echo implode(',', $array) // gives you: value, value2
i have array looks this:
$array = array( array('admin_options' => 'test'), array('test_options' => 'test'), )
i want exact same thing implode but out set should this:
array,array
the reason because can pass these 2 arrays, comma separated, function or class parameters arrays.
so in exmple:
if have next class:
class test{ public function __construct(array $options, array $second_options){} }
then should looking @ essentially:
public function __construct(array, array){}
note:
this same function should work if have array looks like:
$array = array( array('admin_options' => 'test'), array('test_options' => 'test'), some_param, some_other_param )
my out set should be:
array, array, some_param, some_other_param
i hope helps clarify question.
i know if seek , utilize implode illegal string conversion of array. thats why need function similar it.
i think work:
$count = 0; foreach($multidimarray $name=>$value) { $varname = 'array'.$count++; $$varname = array("name"=>$value); }
i haven't run yet check syntax, should yield several array variables named $array0, etc. same values each entry in multi-dimensional array.
php arrays multidimensional-array implode
No comments:
Post a Comment