-4
Possible Duplicate:
Merge arrays (PHP)如何在PHP中合并两个具有相同ID的数组?
这是aray我的数组如何将数组与他的'panid'合并在一起。 同样的'panid'请参阅数组和所需的输出。
显示下面的数组2个数组包含相同的'panid',但它的成分是不同的。 所以我会合并这两个数组与合并他的成分。
Array
(
[0] => stdClass Object
(
[userid] => 62
[panid] => 5
[recipeid] => 13
[ingredients] => 10 Kilos,1 Gram
[panname] => XYZ
)
[1] => stdClass Object
(
[userid] => 62
[panid] => 5
[recipeid] => 12
[ingredients] => 150 Gram,15 Pcs
[panname] => XYZ
)
[2] => stdClass Object
(
[userid] => 62
[panid] => 3
[recipeid] => 15
[ingredients] => 100 Gram,10 Pcs
[panname] => ABC
)
)
要求输出:
Array
(
[0] => stdClass Object
(
[userid] => 62
[panid] => 5
[ingredients] => 10 Kilos,1 Gram,150 Gram,15 Pcs
[panname] => XYZ
)
[1] => stdClass Object
(
[userid] => 62
[panid] => 3
[ingredients] => 100 Gram,10 Pcs
[panname] => ABC
)
)
感谢兄弟.... – GKumar00
但它抛出的错误: 开捕致命错误:传递给RecipeStorage参数1 ::连接()必须是对象的实例,stdClass的实例给出,堪称/ home6/panchsof /public_html/dinnerrush/recipe.php在第63行,并在第10行的/home6/panchsof/public_html/dinnerrush/recipe.php中定义了 – GKumar00
@ GKumar00我说这是未经测试的。你将不得不使它适合你的数据;我无法全程握住你的手...... – adlawson