从 2 个 php 数组中过滤唯一数组 std 对象数据
我有 2 个 std 对象数组,我需要过滤掉数组 -> stdClass 对象 ->匹配 [code] 并获得具有唯一数组的最终数组 -> stdClass 对象 -> [代码] 这是数组 #1 的示例
Array
(
[0] => stdClass Object
(
[code] => 100
[c_price] => 438
)
[1] => stdClass Object
(
[code] => 1100
[c_price] => 105
)
)
这是数组 #2 的示例
Array
(
[0] => stdClass Object
(
[code] => 100
[c_price] => 1250
)
[1] => stdClass Object
(
[code] => 1100
[c_price] => 300
)
[2] => stdClass Object
(
[code] => 4807
[c_price] => 1000
)
)
我想要得到的预期结果
Array
(
[0] => stdClass Object
(
[code] => 4807
[c_price] => 1000
)
)
我已经尝试了很多答案,但没有找到更接近我的问题的答案,我已经尝试过 array_unique 但由于 std 对象类而无法工作,提前致谢
I have 2 array of std objects where i need to filter out array -> stdClass Object -> matching [code] and get final array with unique array -> stdClass Object -> [code]
here are examples array #1
Array
(
[0] => stdClass Object
(
[code] => 100
[c_price] => 438
)
[1] => stdClass Object
(
[code] => 1100
[c_price] => 105
)
)
here are examples array #2
Array
(
[0] => stdClass Object
(
[code] => 100
[c_price] => 1250
)
[1] => stdClass Object
(
[code] => 1100
[c_price] => 300
)
[2] => stdClass Object
(
[code] => 4807
[c_price] => 1000
)
)
Expected results i want to get
Array
(
[0] => stdClass Object
(
[code] => 4807
[c_price] => 1000
)
)
i have tried many answers but not found any closer to my problem, i have tried array_unique but it's not working because of std object class, thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了
欢呼@ Kiran Rai Chamling
solved with
cheers @ Kiran Rai Chamling