Latest news
Home » PHP » usort() function Issue with PHP 5.3

usort() function Issue with PHP 5.3

There is an issue existing with usort() function. Problem is purely related to php version, the old syntax is not work  well in php 5.3

Here is the fix for usort() function Issue with PHP 5.3

usort($aResult, function ($elem1, $elem2) {
return strcmp($elem1[‘title’], $elem2[‘title’]);
});

solution

Use a different function.

usort($aResult,”mySort“);

function mySort($elem1,$elem2){
return strcmp($elem1[‘title’], $elem2[‘title’]);
}

One comment

  1. is this function removed by php authoririties..

Leave a Reply

x

Check Also

How to print Codeigniter upload error

if you want to display errors on upload functionality in codeigniter. Use the following function ...