Sort multidimensional array by multiple columns

You need array_multisort $mylist = array( array(‘ID’ => 1, ‘title’ => ‘Boring Meeting’, ‘event_type’ => ‘meeting’), array(‘ID’ => 2, ‘title’ => ‘Find My Stapler’, ‘event_type’ => ‘meeting’), array(‘ID’ => 3, ‘title’ => ‘Mario Party’, ‘event_type’ => ‘party’), array(‘ID’ => 4, ‘title’ => ‘Duct Tape Party’, ‘event_type’ => ‘party’) ); # get a list of sort … Read more

Submitting a multidimensional array via POST with php

On submitting, you would get an array as if created like this: $_POST[‘topdiameter’] = array( ‘first value’, ‘second value’ ); $_POST[‘bottomdiameter’] = array( ‘first value’, ‘second value’ ); However, I would suggest changing your form names to this format instead: name=”diameters[0][top]” name=”diameters[0][bottom]” name=”diameters[1][top]” name=”diameters[1][bottom]” … Using that format, it’s much easier to loop through the … Read more

Map a 2D array onto a 1D array

You need to decide whether the array elements will be stored in row order or column order and then be consistent about it. http://en.wikipedia.org/wiki/Row-major_order The C language uses row order for Multidimensional arrays To simulate this with a single dimensional array, you multiply the row index by the width, and add the column index thus: … Read more