PHP how to spilt two array -
i have array like:
array(2) { ["y"]=> string(1) "a" ["z"]=> string(3) "1,2" }
i want print them as:
array(2) { ["y"]=> string(1) "a" ["z"]=> string(1) "107"},array(2) { ["y"]=> string(1) "a" ["z"]=> string(1) "2"}
here code:
$a = explode(",",$row['z']);
assuming want print like...
array(2) { ["y"]=> string(1) "a" ["z"]=> string(1) "1"} array(2) { ["y"]=> string(1) "a" ["z"]=> string(1) "3"}
...
then should work.
$rowsplitted = array(); $zvalues = explode(',', $row['z']) $yvalue = $row['y'] foreach ($zvalues $zvalue) { $rowsplitted[] = array( 'y' => $yvalue, 'z' => $zvalue, ]; }
Comments
Post a Comment