zartzar Posted March 16, 2009 Share Posted March 16, 2009 <?php $comments=$_POST['comments']; $parray=explode(' ', $comments); $parraydup=array_unique($parray); $parrayalpha=sort($parraydup); $pstring=implode(' ',$parrayalpha); print "$pstring"; ?> i just get a error Link to comment https://forums.phpfreaks.com/topic/149719-solved-why-wont-my-array-sort/ Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 What's the error? Link to comment https://forums.phpfreaks.com/topic/149719-solved-why-wont-my-array-sort/#findComment-786203 Share on other sites More sharing options...
zartzar Posted March 16, 2009 Author Share Posted March 16, 2009 What's the error? Warning: implode() [function.implode]: Invalid arguments passed in <directory> line number 37 (yeah, where i use the implode function) Link to comment https://forums.phpfreaks.com/topic/149719-solved-why-wont-my-array-sort/#findComment-786206 Share on other sites More sharing options...
trq Posted March 16, 2009 Share Posted March 16, 2009 sort returns a booleen not an array. <?php $comments=$_POST['comments']; $parray=explode(' ', $comments); $parraydup=array_unique($parray); sort($parraydup); $pstring=implode(' ',$parraydup); print $pstring; ?> Link to comment https://forums.phpfreaks.com/topic/149719-solved-why-wont-my-array-sort/#findComment-786210 Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 That's because sort returns a boolean and you're trying to implode on it. Link to comment https://forums.phpfreaks.com/topic/149719-solved-why-wont-my-array-sort/#findComment-786211 Share on other sites More sharing options...
zartzar Posted March 16, 2009 Author Share Posted March 16, 2009 Ok, so how do i fix this? :'( Link to comment https://forums.phpfreaks.com/topic/149719-solved-why-wont-my-array-sort/#findComment-786234 Share on other sites More sharing options...
Mark Baker Posted March 16, 2009 Share Posted March 16, 2009 Ok, so how do i fix this? :'( As thorpe has swn you three replies above Link to comment https://forums.phpfreaks.com/topic/149719-solved-why-wont-my-array-sort/#findComment-786247 Share on other sites More sharing options...
zartzar Posted March 16, 2009 Author Share Posted March 16, 2009 Ok, so how do i fix this? :'( As thorpe has swn you three replies above whoops, my bad, im so tired. thanks thorpe! Link to comment https://forums.phpfreaks.com/topic/149719-solved-why-wont-my-array-sort/#findComment-786257 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.