Skip to content
Advertisement

php array: if identical key values then choose highest by other key value

JavaScript

I have an array with the given Keys like above. I need a new array that gives me the highest Version IF module is same. How would I do that?

JavaScript

This is what I tried

JavaScript

Advertisement

Answer

I tried to debug your code though.The problem is that you try to access element [0] of $moduleF. You should change $moduleF[$j][‘Module’] to $moduleF[‘Module’].

Use standard functions where possible. for finding values within (multidimensional) array’s you can use array_search. The code beneath works.

Also don’t compare strings with == use strcmp(str1, str2) == 0 instead

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement