dreamwest Posted July 4, 2010 Share Posted July 4, 2010 Why cant i shuffle a merged array? $arr[] = array('id' => 0, 'title' => funny); $latest[] = array('id' => 23, 'title' => second); $blend = array_merge($latest,$arr); print_r(shuffle($blend)); Quote Link to comment https://forums.phpfreaks.com/topic/206674-shuffle/ Share on other sites More sharing options...
kenrbnsn Posted July 4, 2010 Share Posted July 4, 2010 The shuffle function returns a boolean (i.e. TRUE or FALSE), not an array, so you can't do <?php print_r($shuffle($blend)); ?> and expect to see the array. You can do <?php shuffle($blend); print_r($blend); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/206674-shuffle/#findComment-1080902 Share on other sites More sharing options...
dreamwest Posted July 4, 2010 Author Share Posted July 4, 2010 ok i tried this but all it return is "1" $arr[] = array('id' => 0, 'title' => funny); $latest[] = array('id' => 23, 'title' => second); $blend = array_merge($latest,$arr); $blend = shuffle($blend); print_r($blend); Quote Link to comment https://forums.phpfreaks.com/topic/206674-shuffle/#findComment-1080906 Share on other sites More sharing options...
kenrbnsn Posted July 4, 2010 Share Posted July 4, 2010 You don't want <?php $blend = shuffle($blend); ?> Do <?php shuffle($blend); ?> Same reasoning as my first post. Ken Quote Link to comment https://forums.phpfreaks.com/topic/206674-shuffle/#findComment-1080914 Share on other sites More sharing options...
dreamwest Posted July 4, 2010 Author Share Posted July 4, 2010 Thanks! works beutifully Quote Link to comment https://forums.phpfreaks.com/topic/206674-shuffle/#findComment-1080919 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.