Sorting a 2 dimensional array in PHP -


wonder if can help;

i have 2 dimensional array need group common "job number" element; here's example - i'm playing idea @ moment, $i counter iterates through array results;

$galleryitems[$i][0] = 'example title';//the title  $galleryitems[$i][1] = 'example description';//description  $galleryitems[$i][2] = 'the client';//client  $galleryitems[$i][3] = '00000';//job number 

any ideas on how group these toegther, eg if had number of 00000 job items stick these toegther, , 00001 group etc.

thanks

$galleryitemsgrouped = array(); foreach($galleryitems $k => $v) {   $galleryitemsgrouped[$v[3]][] = $v; } var_dump($galleryitemsgrouped); 

or maybe that's mean

usort($galleryitems, function($a,$b) {   if($a[3] == $b[3]) return 0;   return $a[3]<$b[3] ? -1 : 1; }); var_dump($galleryitems); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -