bettor
(Live Webscore)
May 3, 2010, 4:17pm
1
Hi. I am performing two queries. Both result sets I array_merge into one array and than I perform a listData to the merged array. However, I would like to sort the listData elements in an alphabetic order. I do that via sort(), however, than I get:
Invalid argument supplied for foreach()
Any advice how to sort the listData would be greatly appreciated.
cheers,
bettor
bettor
(Live Webscore)
May 3, 2010, 5:29pm
3
jayrulez:
use php’s native sort()
thanks for your time jayrulez. As I have mentioned in my post I have already tried sort() but it messes things up and I get the above mentioned error.
jayrulez
(Waprave)
May 3, 2010, 8:06pm
4
Show a sample of the data you are trying to sort.
bettor
(Live Webscore)
May 3, 2010, 8:34pm
5
this doesn’t work:
$allnames=array_merge((array)$names_host,(array)$names_away);
return sort($allnames);
this works tho without the sort:
$allnames=array_merge((array)$names_host,(array)$names_away);
return $allnames;
thanks jayrulez
jayrulez
(Waprave)
May 3, 2010, 10:39pm
6
bettor:
this doesn’t work:
$allnames=array_merge((array)$names_host,(array)$names_away);
return sort($allnames);
this works tho without the sort:
$allnames=array_merge((array)$names_host,(array)$names_away);
return $allnames;
thanks jayrulez
Please have a look at http://php.net/manual/en/function.sort.php
sort returns a boolean value so returning sort will return true or false.
the correct way
$allnames=array_merge((array)$names_host,(array)$names_away);
sort($allnames);
return $allnames;
bettor
(Live Webscore)
May 4, 2010, 7:07am
7
jayrulez:
Please have a look at http://php.net/manual/en/function.sort.php
sort returns a boolean value so returning sort will return true or false.
the correct way
$allnames=array_merge((array)$names_host,(array)$names_away);
sort($allnames);
return $allnames;
Ah, thanks for noticing this.