Skip to content
Advertisement

Tag: multidimensional-array

Sort array by 2nd level array count

I have an array that looks like this: I need to be able to count the 2nd level contents and then sort the top level arrays based on these totals. So for example my resultant array would look something like this: I then ideally want to sort by descending order and show only the top 5 results. At present my

Iterate array of arrays in reverse and subtract following subarray values from current subarray values

I have a dynamic multidimensional array like this: I need to loop through the subarrays and overwrite the current values of each subarray to represent the difference between the original value and the following value with respect to the subarray keys. This describes the arithmetic desired on each subarray element (the value after the = is the new desired value):

Advertisement