[英]want to add or want to merge two new arrays into 3 earlier arrays
array_1 = {"challenge_id":"1","user_id":"2","username":"abc","challenge_balance":"1million","bet":"lyf","challenge_name":"disaster","plan":"enjoy","challenge_type":"Me","c_type":"challenge"}
array 2 = {"challenge_id":"8","user_id":"2","username":"abc","challenge_balance":"1million","bet":"lyf","challenge_name":"disaster","plan":"enjoy","challenge_type":"Me","c_type":"challenge"},
array_3 = {"challenge_id":"9","user_id":"2","username":"abc","challenge_balance":"1million","bet":"lyf","challenge_name":"disaster","plan":"enjoy","challenge_type":"Me","c_type":"challenge"}
another array from different query 来自不同查询的另一个数组
array 1= {"project_id":"1","project_name":"2","description":"testing","p_type":"project","project_balance":"1trillion","hatred_ressented":"dontknow"}
array 2 = {"challenge_id":"9","user_id":"2","username":"abc","challenge_balance":"1million","bet":"lyf","challenge_name":"disaster","plan":"enjoy","challenge_type":"Me","c_type":"challenge"}
I want result should be in 3 arrays which means the first array should be combined with first from both the second array as combined of second from both the third array as array 1 with null. 我希望结果应该在3个数组中,这意味着第一个数组应该与第二个数组中的第一个数组合并,然后再与第三个数组中的第二个数组合并为null。
Simply merge them with array_merge()
只需将它们与
array_merge()
合并
$merge_array = array_merge(first_array, second_array);
Example: 例:
$one = array('one'=>1, 'two'=>2);
$two = array('three'=>1, 'four'=>2);
$three = array('five'=>1, 'six'=>2);
$merge_array = array_merge($one, $two);
$merge_three = array_merge($merge_array, $three);
print_r($merge_three);
//THE result
Array ( [one] => 1 [two] => 2 [three] => 1 [four] => 2 [five] => 1 [six] => 2 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.