The sort
function returns a bool
. Also, exploding / imploding on ';'
won't give you quite what you want. Try using "\n"
instead:
$arr = explode( "\n" , $css );
sort($arr);
echo implode ( "\n", $arr );
If you want to do this all in one line you can write a custom function, like this:
function my_sort($arr) {
sort($arr);
return $arr;
}
And then you can call it like this:
echo implode ( "\n", my_sort( explode( "\n" , $css ) ) );