Skip to content
Advertisement

How to sort an Array in PHP by value?

I know that this is asked before, I even tryied to do as on this question: How to Sort Multi-dimensional Array by Value?

But in my case it doesn’t work. If anybody can help me I will be very thankful.

My code:

JavaScript

I want to sort this array by “reference” in alphabetical order.

I tried this:

JavaScript

But the result is null or empty.

By default the output is:

JavaScript

If I use “usort” I only get 4 empty rows

This si the full code:

JavaScript

Advertisement

Answer

Please sort $product_var_tpl_list, not $product_var_tpl.

Following is sample code.

JavaScript

And test result is as following.

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