Re: Sorting through an array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>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
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux