array
-
(PHP) Sort array of objects by property value
Sort by predefined order:
-
(HTML) Form element arrays
Sometimes you might want to group form elements in arrays. Here’s a way to do that: [html] <form> <input type="text" name="textboxes[]"> <input type="text" name="textboxes[]"> <input type="text" name="textboxes[]"> </form> [/html] The structure of the $_POST array will then be: [php] Array ( [textboxes] => Array ( [0] => value 1 [1] => value 2 [2] =>…
-
(PHP) sorting an array on a specific value
Simple way to sort an array with usort on a specific value using a comparator. [php] usort($myArray, function ($a, $b) { return $a[‘foo’] > $b[‘foo’]; }); [/php]