This question already has an answer here:
I have a form where I'm creating a number of item arrays:
<input type="hidden" value="Full/Double Mattress" name="pickup1-dropoff1Items[1][0]">
<input type="text" name="pickup1-dropoff1Items[1][1]">
<input type="hidden" value="20" name="pickup1-dropoff1Items[1][2]">
<input type="hidden" value="FMat" name="pickup1-dropoff1Items[1][3]">
<input type="hidden" value="1" name="pickup1-dropoff1Items[1][4]">
so the structure is basically:
array(
array('title', quantity, price, 'shorthand', order),
array('title', quantity, price, 'shorthand', order)
)
etc...
I'm getting this information using PHP and sending it in an email. I can get one of these arrays like so:
$pickup1_dropoff1Items = $_POST['pickup1-dropoff1Items'];
I would like to sort the arrays in $pickup1_dropoff1Items
by the 'order' number (i.e. index #4, i.e. $pickup1-dropoff1Items[i][4]
) in each of those arrays.
Can this be done using PHP ksort()? Does anyone have any idea how to sort an array like this using PHP?
Thanks!
</div>