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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -