From 7ae97fa48bc3113e59a494ef88b5e7e32c099d80 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Mon, 4 May 2015 20:10:13 +0200 Subject: [PATCH] Added a new function to sort an associative array by key --- pandora_console/include/functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 2ed57e307e..0aceb19fdc 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2362,4 +2362,12 @@ function set_unless_defined (&$var, $default) { return false; } } + +function sort_by_column (&$array_ref, $column) { + if (!empty($column)) { + usort($array_ref, function ($a, $b) { + return strcmp($a[$column], $b[$column]); + }); + } +} ?>