-4

我想修复php数组。

亲爱的我的数组如下:

$stmyarr=Array ( [0] => [0]=>aaa,[1]=>ddd,[2]=>bbb,[3]=>ccc)

我想删除 [0] =>

所以显示时的结果

Array ([0]=>aaa,[1]=>ddd,[2]=>bbb,[3]=>ccc)

怎么做 ?

4

4 回答 4

4

简单,只需将数组名称重新分配给[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
)
于 2012-08-31T07:14:25.483 回答
0
$stmyarr=array ( '0' => array('0'=>'aaa','1'=>'ddd','2'=>'bbb','3'=>'ccc'));
$stmyarr=current(array_values($stmyarr));
于 2012-08-31T07:22:13.753 回答
0
$stmyarr=array ('0' => array('0'=>'a','1'=>'b','2'=>'c'));
$array = array_values($stmyarr[0]);
print_r($stmyarr);
于 2012-08-31T07:16:53.593 回答
0

只是

$stmyarr = $stmyarr[0];

将来阅读阵列手册肯定会有所帮助。

于 2012-08-31T07:18:18.317 回答