$a = array( '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five',
....
);
$b = array(2,5,4,1,3,.....); // 数组a的key顺序$c = array( '2' => 'two', '5' => 'five', '4' => 'four', '1' => 'one', '3' => 'three',
....
);
2 回答
开心每一天1111
TA贡献1836条经验 获得超13个赞
$a = array( '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five', .... );$b = array(2,5,4,1,3,.....); // 数组a的key顺序$c = array();foreach( $b as $d ) $c[$d] = $a[$d];print_r( $c );
猛跑小猪
TA贡献1858条经验 获得超8个赞
$a = array( '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five');$b = array('2','5','4','1','3'); // 数组a的key顺序$result=array();function sort_key($v){ global $result; global $a; $result[$v]=$a[$v]; }array_walk($b, 'sort_key');print_r($result);
- 2 回答
- 0 关注
- 107 浏览
添加回答
举报
0/150
提交
取消