我在php中合併了兩個數組。這裏是我的代碼我在php的array_merge中遇到問題?
$message = array_merge($message2, $message1);
echo json_encode($message);
在這裏我得到的數據,但在這裏打印「0」和「1」
{"username":"ji5vajng","gender":"MALE","profilepic":"http:\/\/li336-153.members.linode.com\/services\/uploads\/users\/thumbs\/000000000000000Sunset.jpg","status":"1","nickname":"laddu","0":{"username":"i3vnbtcz","gender":"MALE","profilepic":"http:\/\/li336-153.members.linode.com\/services\/uploads\/users\/thumbs\/7BB46853-D79D-5E17-807F-FD0666AF21BBi3vnbtcz-2011-06-13 11:04:26 +0000.png","status":"1","nickname":"Cool"},"1":{"username":"oq5mjbvb","gender":"male","profilepic":"http:\/\/li336-153.members.linode.com\/services\/uploads\/users\/thumbs\/7BB46853-D79D-5E17-807F-FD0666AF21BBoq5mjbvb-2011-06-13 05:45:57 +0000.png","status":"1","nickname":""},"2":{"username":"ejzxm2oz","gender":"MALE","profilepic":"http:\/\/li336-153.members.linode.com\/services\/uploads\/users\/thumbs\/A0000015BAB1CAreceived_0.jpg","status":"1","nickname":"laddu"}}
可以提供一個例子 –
0和1是你的數組索引!你總是可以通過改變你的數組並改變你的數組的鍵來改變它們。 – toopay
iam在上面編輯我的代碼。請參閱上面的代碼 – narayana