fork download
  1. <?php
  2.  
  3. $array = [
  4. [
  5. ['id' => 10, 'text' => 'Latex'],
  6. ['id' => 15, 'text' => 'Occasion Latex'],
  7. ['id' => 82, 'text' => 'Christmas'],
  8. ],
  9. [
  10. ['id' => 11, 'text' => 'Accessories'],
  11. ['id' => 97, 'text' => 'Retail Accessories'],
  12. ['id' => 558, 'text' => 'Super Stuffer'],
  13. ],
  14. [
  15. ['id' => 374, 'text' => 'Party Supplies'],
  16. ['id' => 1488, 'text' => 'Party by Occasion'],
  17. ['id' => 1493, 'text' => 'Christmas'],
  18. ],
  19. ];
  20.  
  21. usort($array, function($a, $b) { return $a[0]['text'] <=> $b[0]['text']; });
  22.  
  23. var_export($array);
Success #stdin #stdout 0.03s 25636KB
stdin
Standard input is empty
stdout
array (
  0 => 
  array (
    0 => 
    array (
      'id' => 11,
      'text' => 'Accessories',
    ),
    1 => 
    array (
      'id' => 97,
      'text' => 'Retail Accessories',
    ),
    2 => 
    array (
      'id' => 558,
      'text' => 'Super Stuffer',
    ),
  ),
  1 => 
  array (
    0 => 
    array (
      'id' => 10,
      'text' => 'Latex',
    ),
    1 => 
    array (
      'id' => 15,
      'text' => 'Occasion Latex',
    ),
    2 => 
    array (
      'id' => 82,
      'text' => 'Christmas',
    ),
  ),
  2 => 
  array (
    0 => 
    array (
      'id' => 374,
      'text' => 'Party Supplies',
    ),
    1 => 
    array (
      'id' => 1488,
      'text' => 'Party by Occasion',
    ),
    2 => 
    array (
      'id' => 1493,
      'text' => 'Christmas',
    ),
  ),
)