I have 3 arrays:
$firstArray = Array([0] => 33 [1] => 34)
$secongArray = Array([0] => 71300 [1] => 72300)
$thirdArray = Array([0] => 71300 [1] => 72300 [2] => 234234)
How do I make it something like this,
$outputArray = array
(
array(33,71300,71300),
array(34,72300,72300),
array(NULL,NULL,234234),
//.....
);
$max = max(count($firstArray),count($secongArray),count($thirdArray));
$outputArray = array();
for($i==0;$i<$max;$i++) {
//test unset values
if(!isset($firstArray[$i])) $firstArray[$i] = null;
if(!isset($secongArray[$i])) $secongArray[$i] = null;
if(!isset($thirdArray[$i])) $thirdArray[$i] = null;
$outputArray[] = array($firstArray[$i],$secongArray[$i],$thirdArray[$i]);
}
$firstArray = array(33, 34);
$secondArray = array(71300, 72300);
$thirdArray = array(71300, 72300, 234234);
$outputArray = call_user_func_array(
'array_map',
array_merge(
array(NULL),
array(
$firstArray,
$secondArray,
$thirdArray
)
)
);
var_dump($outputArray);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.