suttercain Posted April 10, 2007 Share Posted April 10, 2007 I have this line of code: echo explode (", ", $row['characters']); But all I get is an echo of 1. When I ran the print_r it returned the array with the values. Is it possible to sort the explode array? Thanks. SC Link to comment https://forums.phpfreaks.com/topic/46381-solved-can-you-sortexplodevariable/ Share on other sites More sharing options...
AndyB Posted April 10, 2007 Share Posted April 10, 2007 explode is a function, you can't echo it. explode the string into an array (that's what explode() does), then sort the array, then do whatever you want with it. array sort functions can be found in the manual at http://ca.php.net/manual/en/ref.array.php Link to comment https://forums.phpfreaks.com/topic/46381-solved-can-you-sortexplodevariable/#findComment-225583 Share on other sites More sharing options...
suttercain Posted April 10, 2007 Author Share Posted April 10, 2007 Hi Andy, Thanks for the reply. I have also tried: $people = explode (", ", $row['characters']); echo sort($people); AND $people = explode (", ", $row['characters']); echo arsort($people); Both with the same results, an output of 1. Link to comment https://forums.phpfreaks.com/topic/46381-solved-can-you-sortexplodevariable/#findComment-225586 Share on other sites More sharing options...
fert Posted April 10, 2007 Share Posted April 10, 2007 sort and asort either return a 1 or a 0 Link to comment https://forums.phpfreaks.com/topic/46381-solved-can-you-sortexplodevariable/#findComment-225588 Share on other sites More sharing options...
suttercain Posted April 10, 2007 Author Share Posted April 10, 2007 got it, i did a foreach Thanks guys Link to comment https://forums.phpfreaks.com/topic/46381-solved-can-you-sortexplodevariable/#findComment-225589 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.