According to the documentation ksort()
always returns a boolean and the array is modified by reference.
You could assign the result of ksort()
to a unused variable and use the array for your output like this.
{$tmp = ksort($var)}
{$var}
Question
i am trying to ksort an array, it worked when i was working with php, but i tried this in smarty template it didnt worked..
i tried like this
{{ksort($var)}}
but it returned this bool value and it even prints it..
1
actual array in $var is
array(1) { [1]=> array(2) { ["Name"]=> NULL ["SubMenu"]=> array(1) { [1]=> array(1) { ["SubName"]=> NULL } } } }
I have even tried {{$var = ksort($var)}}
but it just store that bool value.
any ideas how to ksort this array in smarty??
Solution
According to the documentation ksort()
always returns a boolean and the array is modified by reference.
You could assign the result of ksort()
to a unused variable and use the array for your output like this.
{$tmp = ksort($var)}
{$var}