Combine single and multidimensional array using php -
I have 2 arrays and I have both arrays.If match to array 1 array2 After joining, I would like to be like the last array So I would like to include Any indication / suggestions are very welcome Thanks in advance. I do not know the shortest way to go there, but you can get all the p Compare weeks. After receiving the differences, assign one, then sort them at the end. array 1
array 2 , then I would like to keep
0 for that element.
$ weeks array = array ("P1", "P2", "P3", "P4"); Array ("P1", "123"), "1" => Array ("p1", "123"); array ("p2"); array 2
$ dailyArr = array ("0" => , "125"), "2" => array ("P4", "126"));
$ finalArr = array ("0" => array ("p1", "Array (" p3 "," 0 ")," 3 "=> array (" p4 ", 123"), "1" => array ("P2", "125"), "2 "= & Gt;" 126 "));
p3 in the final code.
$ weeksArr = array ("p1" "p2", "p3", "p4"); $ DailyArr = array ("0" = & gt; array ("p1", "123"), "1" => array ("p2", "125"), "2" => array ( "P4", "126")); $ End hour = $ daily; $ Temp = array_map (function ($ piece) {piece of return dollar [0];}, $ finals arrr); // Get $ diff = array_diff ($ weekout, $ temp) of all p; // Get the missing P. ($ $ $ $ w) as {$ finalArr [] = array ($ w, 0); // unavailable P} usort ($ finalArr, function ($ a, $ b) {// You do not need it, you do not care about order return strcmp ($ a [0], $ b [0]) ; // If you need to order them, P1, P2, P3, P4, then I think you need to sort it}); Echo '& lt; Pre & gt; '; Print_r ($ finalArr);
Comments
Post a Comment