使用嵌套标准类对象按特定值对多维数组进行分组
在上一篇文章中,有一个关于分组多维数组的非常有用的答案。我的问题与我的初始数组有一个嵌套标准类对象的问题类似。我的数组看起来像这样:
Array
(
[0] => stdClass Object
(
[InstallationAddress2] => LAKEWOOD, CA 90000
[LineitemmasterDescription] => Apples
[Workorder_id] => W008052094
)
[1] => stdClass Object
(
[InstallationAddress2] => Santa Rosa, CA 90230
[LineitemmasterDescription] => Berries
[Workorder_id] => W008022342
)
[2] => stdClass Object
(
[InstallationAddress2] => LAKEWOOD, CA 90000
[LineitemmasterDescription] => Apples
[Workorder_id] => W008052094
)
)
就像上一篇文章一样,我希望得到类似的东西
Array
(
Array (
[0] => Array
(
[InstallationAddress2] => LAKEWOOD, CA 90000
[LineitemmasterDescription] => Apples
[Workorder_id] => W008052094
)
[1] => Array
(
[InstallationAddress2] => LAKEWOOD, CA 90000
[LineitemmasterDescription] => Apples
[Workorder_id] => W008052094
)
)
Array (
[2] => Array
(
[InstallationAddress2] => Santa Rosa, CA 90230
[LineitemmasterDescription] => Berries
[Workorder_id] => W008022342
)
)
)
我绊倒的是标准类对象,它拒绝转换为数组。
In a previous post there was a very helpful answer on grouping multidimensional arrays. My issue is similar with the twist that my initial array has a nested standard class object. My array looks like this:
Array
(
[0] => stdClass Object
(
[InstallationAddress2] => LAKEWOOD, CA 90000
[LineitemmasterDescription] => Apples
[Workorder_id] => W008052094
)
[1] => stdClass Object
(
[InstallationAddress2] => Santa Rosa, CA 90230
[LineitemmasterDescription] => Berries
[Workorder_id] => W008022342
)
[2] => stdClass Object
(
[InstallationAddress2] => LAKEWOOD, CA 90000
[LineitemmasterDescription] => Apples
[Workorder_id] => W008052094
)
)
Like the previous post I'm hoping to get something like
Array
(
Array (
[0] => Array
(
[InstallationAddress2] => LAKEWOOD, CA 90000
[LineitemmasterDescription] => Apples
[Workorder_id] => W008052094
)
[1] => Array
(
[InstallationAddress2] => LAKEWOOD, CA 90000
[LineitemmasterDescription] => Apples
[Workorder_id] => W008052094
)
)
Array (
[2] => Array
(
[InstallationAddress2] => Santa Rosa, CA 90230
[LineitemmasterDescription] => Berries
[Workorder_id] => W008022342
)
)
)
The thing I'm stumbling over is the standard class object which refuses to be cast into an array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以轻松地将 stdClass 转换为数组...
更有趣的问题:您从哪里获得这个数组?
You can easily cast an stdClass to an array ...
The more-interesting question: Where did you get this array?