Here is my code that is ok - but issue is it only works if I ignore the sort altogether and go back to using unsorted array.
array_push($closest, "PM"); array_push($closest, "FF"); array_push($closest, "LM"); array_push($closest, "AL"); // Sort the list
$myranwin = rand(0,$number);
Output LM or whatever.
I looked into it by printing each step to screen. If I print out $sorted i.e. print join(",", $sorted);- I get
join(): Invalid arguments passed (line 13) AL
that is just the first member of the array - and this one only member of the array persists through the rest of the program, I think the invalid argument comes up because $sorted = sort($closest) is not an array, therefore I can't work with it.
I know I could avoid the question by just using sort = ... though I don't understand why its in the exercise if it makes no difference.
What I am wondering is does this mean I can only save a manipulated array by explicitly creating a separate array, $sort=array()? Or have I missed something? And what is the program actually doing when I write $sorted = sort($closest);? Is it just saving the first element it encounters as a variable?