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 Quote 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? Quote 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) Quote 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; ?> Quote 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. Quote 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? :'( Quote 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 Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.