Home  >  Article  >  Backend Development  >  合拼成二维数组后,二维数组的键名是0,不是字符串.

合拼成二维数组后,二维数组的键名是0,不是字符串.

WBOY
WBOYOriginal
2016-06-20 12:43:25972browse

$arr = Array(    [id] => 312355    [num] => 2231231    [url] => http://www.aba.com/add.php    [name] => 林    [idNum] => 44090000000000    [pNum] => 18955501    [0] => Array        (            [cus] => aaa            [amo] => 100            [fre] => 0            [Amount] => 100            [t] => 0            [me] =>             [Name] =>         ) )


如何把 $arr[0]的键名修改成 $arr['aaaa']


回复讨论(解决方案)

$arr['aaaa'] = $arr[0];unset($arr[0]);

你在合并时就命名不可以吗?

要看你是怎么合并的?
或者合并的时候就写成aaa

你在合并时就命名不可以吗?



array_push($data,$chiddenCI);
 $data['chiddenCI'] = $data[0];
  unset($data[0]);
print_r($data);
是通过 array_push 来合并的.

通过array_push 合并也可以

为什么是
array_push($data,$chiddenCI);

直接这样不就行了?
$data['chiddenCI'] = $chiddenCI;
 

为什么是
array_push($data,$chiddenCI);

直接这样不就行了?
$data['chiddenCI'] = $chiddenCI;
 



哈哈.是哦.我真晕,看来坐着写代码是没用的.得站起来像想东西.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn