PHP sorting arrays numerically by key value

Trent

New Member
I'm trying to sort several arrays in numerical order based on the value in their first key:\[code\]$array1[0] = '1';$array1[1] = 'content';$array1[2] = 'more content';$array3[0] = '3';$array3[1] = 'content';$array3[2] = 'more content';$array4[0] = '4';$array4[1] = 'content';$array4[2] = 'more content';$array2[0] = '2';$array2[1] = 'content';$array2[2] = 'more content';$arrays = array($array1, $array3, $array4, $array2);foreach ($arrays as $array) {echo $array[0] . ' ' . $array[1] . ' ' . $array[2] . '<br>';}\[/code\]That outputs the arrays in a '1, 3, 4, 2' sequence, I need them to be output thusly: '1, 2, 3, 4'. Not sure how or even if to use the ksort/asort/array_multisort functions here.
 
Back
Top