How to sort an array in alphabetical order using codeigniter

How to sort an array in alphabetical order using codeigniter

array(
     Array(

            [id] => 4
            [business_category] => Air_conditioning-Auto
            [business_name] => test business
        );
      Array(

            [id] => 55
            [business_category] => Air_conditioning-Auto
            [business_name] => asdf
        );
);

Answers


Answer taken from this post: Sort array of objects by object fields

Use usort, here's an example adapted from the manual:

function cmp($a, $b)
{
    return strcmp($a->name, $b->name);
}

usort($your_data, "cmp");

If you're sorting the array from inside the class and your sorting function cmp is also defined inside the class, then use this:

usort($your_data, array($this, "cmp"))

Need Your Help

Take Access DB from PC to Web Version

php mysql html ms-access ms-office

Project: Turn an Access DB into a Web Based application.

Remove columns with values 0 or 999999

python python-3.x pandas data-analysis

I am working with a large data set with 400 columns some of the columns have all values zero and others have all zeros with few '999999999'. I want to get rid of such columns. I was able to do it f...