Skip to content
Advertisement

Tag: multidimensional-array

Add new dimension to array in php [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 8 months ago. Improve this question I don’t know how to ask the question.My goal is : convert : into : Answer Start with the value to be assigned, then for-loop

How do I compared 2 nested index lengths?

First time posting here, I try to follow the questioning guides, sorry if I missed something. I got a multidimensional array in PHP that do not have the same amount of results. Array[0] contains 6 while Array[1] only contains 4. here’s an example: I managed to sum these 2 multidimentional arrays, using the following code: So my result is: So

json encode specific object’s property

I have an array: I want to return a json_encode for this array, but only for “key2” and “key3” attributes. For the moment that: But this is not okay as the array may also contain other properties. If it is possible, I prefer not to use loops… (sorry for my english) Answer This solution uses array_map() and array_intersect_key(): …which prints:

Advertisement