当前位置:Gxlcms > PHP教程 > 数组整合好难哦求帮忙

数组整合好难哦求帮忙

时间:2021-07-01 10:21:17 帮助过:31人阅读

Array(    [0] => Array        (            [0] =>             [1] =>             [2] =>             [3] =>             [4] => 134578        )    [1] => Array        (            [0] => 1            [1] => 9            [2] => 0            [3] => 7            [4] => 8        )    [3]....    [4]....)


整合成
ayyay([0]=>1,[1]=>9,[2]=>0,[3]=>7,[4]=>8134578,)


回复讨论(解决方案)

$array=array(array(1,2,3,4,5),array(6,7,8,9,10));$newArr=array();foreach($array as $k=>$v){    foreach ($v as $k2=>$v)    {        if(empty($newArr[$k2]))        {            $newArr[$k2]=$v;        }        else if($newArr[$k2]<=$v)        {            $newArr[$k2]=$v;        }    }}print_r($newArr);

3,4 键的值参与整合合吗,请说清楚整合规则。

3 4要整合啊 1楼的盆友貌似不对 - -

$a = array(  array('', '', '', '', 134578),  array(1, 9, 0, 7, 8),);$r = call_user_func_array('array_map', array_merge(array(null), array_reverse($a)));$r = array_map('join', $r);print_r($r);
Array(    [0] => 1    [1] => 9    [2] => 0    [3] => 7    [4] => 8134578)

$arr = Array(    0 => Array        (            0 => '',            1 => '',            2 => '',            3 => '',            4 => 134578        ),     1 => Array        (            0 => 1,            1 => 9,            2 => 0,            3 => 7,            4 => 8,        ));$t = array();foreach(array_reverse($arr) as $val){	foreach($val as $k=>$v){		if(!isset($t[$k])) $t[$k] = $v;	    else $t[$k] .= $v;	} }print_r($t);

人气教程排行