PHP array常用——V

1.array_values   将关联数组变为索引数组

$array = array('1'=>['id'=>'a','other'=>1],
               '2'=>['id'=>'b','other'=>2],
               '3'=>['id'=>'b','other'=>3],
               '05'=>['id'=>'','other'=>5],
               '4'=>['id'=>'','other'=>4]);
$res = array_merge($array);
$res = array_values($res);
print_r(json_encode($res));

输出:[
{"id":"a","other":1},{"id":"b","other":2},
{"id":"b","other":3},{"id":"","other":5},
{"id":"","other":4}
]

猜你喜欢

转载自blog.csdn.net/qq_30923243/article/details/83056370