From 12f68b290b296e511e71b00d1c407eb85dd93f5b Mon Sep 17 00:00:00 2001 From: sparkyx Date: Tue, 2 Dec 2025 16:20:13 +0100 Subject: [PATCH] new function to convert array to array for ISelect --- include/lib/ac_common.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 8e931618d..6a68c149f 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -2029,3 +2029,20 @@ function convert_ini_unit($p_value) return $p_value; } +/** + * @brief convert an array KEY=>VALUE into a double array useable by \ISelect + * @param $array (array) array key=>value + * @return double array array (array('value'=>'KEY','label'=>VALUE),...)) + * @see ISelect + */ +function convert_array_select($array) +{ + if (count($array) == 0 ) return null; + $a_ret=array();$i=0; + foreach ($array as $key=>$value) { + $a_ret[$i]['value']=$key; + $a_ret[$i]['label']=$value; + $i++; + } + return $a_ret; +} \ No newline at end of file