echo $existing_data;
echo $current_data;
array_merge($existing_data->original, $current_data->original);
array_merge($existing_data->large, $current_data->large);
array_merge($existing_data->small, $current_data->small);
echo $existing_data;
输出为:
"existing": {
"original": [],
"small": [],
"large": [],
"preview": {
"name": "",
"path": "",
"reference": ""
}
}
"current": {
"original": [
{
"name": "TQT_82560100_1385618474_9480",
"created_timestamp": "2013-11-28 06:01:14",
}
],
"small": [
{
"name": "TQT_82560100_1385618474_9480_small",
"created_timestamp": "2013-11-28 06:01:15",
}a
],
"large": [
{
"name": "TQT_82560100_1385618474_9480_large",
"created_timestamp": "2013-11-28 06:01:15",
}
],
"preview": {
"name": "TQT_82560100_1385618474_9480_prev",
"path": "images/",
"reference": 0,
"width": 137,
"height": 137
}
}
"existing": {
"original": [],
"small": [],
"large": [],
"preview": {
"name": "",
"path": "",
"reference": ""
}
}
我也试过了array_merge_recursive()
。但结果相同。
答案 0 :(得分:1)
你必须保存数组合并的结果
$result = array_merge($existing_data->original, $current_data->original);
php docs的例子
<?php
$array1 = array("color" => "red", 2, 4);
$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
$result = array_merge($array1, $array2);
print_r($result);
?>
阵列( [color] =&gt;绿色 [0] =&gt; 2 [1] =&gt; 4 [2] =&gt;一个 [3] =&gt; b [形状] =&gt;梯形 [4] =&gt; 4)
答案 1 :(得分:1)
尝试这样做 -
$array1 = $existing_data->original + $current_data->original;
$array2 = $existing_data->large + $current_data->large;
$array3 = $existing_data->small + $current_data->small;