我有兩個數組像這樣,array_replace_recursive()在這種情況下不工作,因爲我編輯相同的更多的澄清。從PHP中合併兩個數組得到一個選擇查詢:更新
Array
(
[0] => stdClass Object
(
[Author] => 1
[totalComments] => 5
[commentsPoints] => 900
[commentDateDiffpoints] => 460
)
[1] => stdClass Object
(
[Author] => 2
[totalComments] => 4
[commentsPoints] => 720
[commentDateDiffpoints] => 24
)
[2] => stdClass Object
(
[Author] => 3
[totalComments] => 4
[commentsPoints] => 720
[commentDateDiffpoints] => 24
)
[3] => stdClass Object
(
[Author] => 18
[totalComments] => 4
[commentsPoints] => 720
[commentDateDiffpoints] => 24
)
)
和
Array
(
[0] => stdClass Object
(
[Author] => 1
[totalLikesGiven] => 5
[likesGivenOnTopicPoints] => 36
[likesGivenOnReplyPoints] => 108
[likesGivenOnBlogPoints] => 36
[DateDiffTopicpoints] => 1
[DateDiffReplypoints] => 3
[DateDiffBlogpoints] => 1
)
[1] => stdClass Object
(
[Author] => 3
[totalLikesGiven] => 1
[likesGivenOnTopicPoints] => 0
[likesGivenOnReplyPoints] => 0
[likesGivenOnBlogPoints] => 36
[DateDiffTopicpoints] => 0
[DateDiffReplypoints] => 0
[DateDiffBlogpoints] => 1
)
)
我喜歡這樣的結果
Array
(
[0] => stdClass Object
(
[Author] => 1
[totalComments] => 5
[commentsPoints] => 900
[commentDateDiffpoints] => 460
[totalLikesGiven] => 5
[likesGivenOnTopicPoints] => 36
[likesGivenOnReplyPoints] => 108
[likesGivenOnBlogPoints] => 36
[DateDiffTopicpoints] => 1
[DateDiffReplypoints] => 3
[DateDiffBlogpoints] => 1
)
[1] => stdClass Object
(
[Author] => 2
[totalComments] => 4
[commentsPoints] => 720
[commentDateDiffpoints] => 24
)
[2] => stdClass Object
(
[Author] => 3
[totalComments] => 4
[commentsPoints] => 720
[commentDateDiffpoints] => 24
[totalLikesGiven] => 1
[likesGivenOnTopicPoints] => 0
[likesGivenOnReplyPoints] => 0
[likesGivenOnBlogPoints] => 36
[DateDiffTopicpoints] => 0
[DateDiffReplypoints] => 0
[DateDiffBlogpoints] => 1
)
[3] => stdClass Object
(
[Author] => 18
[totalComments] => 4
[commentsPoints] => 720
[commentDateDiffpoints] => 24
)
)
請幫助我該怎麼辦在PHP一樣。
數組中對象的提示。它極大地幫助您將數據庫中的主鍵用作陣列的關鍵。 這樣你可以更快地找到你的對象 –