javascript - masalah pemisahan tatasusunan php
phpcn_u1582
phpcn_u1582 2017-05-27 17:43:57
0
2
584

phpcn_u1582
phpcn_u1582

membalas semua(2)
左手右手慢动作
<?php
$arr = [
    [1,'A'],
    [2,'B'],
    [3,'C'],
    [4,'D'],
    [5,'A'],
    [6,'B'],
    [7,'C'],
    [8,'D']
];
$temp = [];
foreach($arr as $value){
    if(array_key_exists($value[1],$temp)){
        array_push($temp[$value[1]],$value);
    }else{
        $temp[$value[1]] = [];
        array_push($temp[$value[1]],$value);
    }
}
var_dump(array_values($temp));
PHPzhong

$arr=array(

    array(1=>'A'),
    array(2=>'B'),
    array(3=>'C'),
    array(4=>'D'),
    array(5=>'A'),
    array(6=>'B'),
    array(7=>'C'),
    array(8=>'D'),
);

$res=array();
foreach ($arr as $key => $value) {

foreach ($value as $k => $v) {
    $res[$v][$k]=$v;
}

}
$res=array_values($res);
echo "<pre>";print_r($res);die();

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan