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

Export Database using codeigniter

Database Utility Class : CodeIgniter PHP script to download mysql db-codeigniter,Backup MySQL database with CodeIgniter ...