我想修复php数组。
亲爱的我的数组如下:
$stmyarr=Array ( [0] => [0]=>aaa,[1]=>ddd,[2]=>bbb,[3]=>ccc)
我想删除 [0] =>
所以显示时的结果
Array ([0]=>aaa,[1]=>ddd,[2]=>bbb,[3]=>ccc)
怎么做 ?
我想修复php数组。
亲爱的我的数组如下:
$stmyarr=Array ( [0] => [0]=>aaa,[1]=>ddd,[2]=>bbb,[3]=>ccc)
我想删除 [0] =>
所以显示时的结果
Array ([0]=>aaa,[1]=>ddd,[2]=>bbb,[3]=>ccc)
怎么做 ?
简单,只需将数组名称重新分配给[0]
// after your original $stmyarr
$stmyarr = array(0 => array( 0 => 'aaa', 1 => 'ddd', 2 => 'bbb', 3 => 'ccc'));
$stmyarr = $stmyarr[0];
print_r($stmyarr);
结果是:
Array
(
[0] => aaa
[1] => ddd
[2] => bbb
[3] => ccc
)
$stmyarr=array ( '0' => array('0'=>'aaa','1'=>'ddd','2'=>'bbb','3'=>'ccc'));
$stmyarr=current(array_values($stmyarr));
$stmyarr=array ('0' => array('0'=>'a','1'=>'b','2'=>'c'));
$array = array_values($stmyarr[0]);
print_r($stmyarr);