Re: Sorting through an array
| From: | Stefan A. | Date: | Tue, 06 May 2014 05:29:08 +0000 |
| Subject: | Re: Sorting through an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323242@lists.php.net to get a copy of this message | ||
Hi,
Something like
uasort($result, function($a, $b) { return strcmp($a['bibleAnagramWord'],
$b['bibleAnagramWord']; });
Replace strcmp with strcasecmp if you want case insensitive comparison.
Hope this helps.
On Tue, May 6, 2014 at 6:26 AM, Ron Piggott
<ron.piggott@actsministries.org>wrote:
>
> How can I sort this array alphabetically by “ bibleAnagramWord “ ---
> keeping it with the same “ reference “ and “ most_popular_views “ values?
>
> $result = Array
> (
> [0] => Array
> (
> [reference] => 10
> [bibleAnagramWord] => Faith
> [most_popular_views] => 325
> )
>
> [1] => Array
> (
> [reference] => 24
> [bibleAnagramWord] => Prayer [most_popular_views] => 270
> )
>
> [2] => Array
> (
> [reference] => 12
> [bibleAnagramWord] => Joy
> [most_popular_views] => 233
> )
>
> [3] => Array
> (
> [reference] => 4
> [bibleAnagramWord] => Forgiveness
> [most_popular_views] => 223
> )
>
> [4] => Array
> (
> [reference] => 16
> [bibleAnagramWord] => Pentecost
> [most_popular_views] => 168
> )
>
> [5] => Array
> (
> [reference] => 91
> [bibleAnagramWord] => Last Supper
> [most_popular_views] => 146
> )
>
> [6] => Array
> (
> [reference] => 44
> [bibleAnagramWord] => Adopted
> [most_popular_views] => 144
> )
>
> [7] => Array
> (
> [reference] => 5
> [bibleAnagramWord] => Easter
> [most_popular_views] => 139
> )
>
> [8] => Array
> (
> [reference] => 214
> [bibleAnagramWord] => Rock
> [most_popular_views] => 133
> )
>
> [9] => Array
> (
> [reference] => 86
> [bibleAnagramWord] => Discipline
> [most_popular_views] => 124
> )
>
> );
>
> Ron Piggott
>
>
>
> www.TheVerseOfTheDay.info
>