CallMeDiz Posted November 9, 2012 Share Posted November 9, 2012 (edited) Hey guys i've got a rookie question. How do i shuffle an array then display each number in the array using implode? Heres my code. $maximum_integer = strip_tags(trim($_REQUEST['maximum_integer'])); $range = range(0,$maximum_integer); $range_randomized[] = shuffle($range); $random_range_imploded = implode(', ', $range_randomized); print $random_range_imploded; it just keeps displaying '1'.... Thanks! Edited November 9, 2012 by CallMeDiz Quote Link to comment https://forums.phpfreaks.com/topic/270488-how-to-shuffle-an-array-then-implode-it/ Share on other sites More sharing options...
DavidAM Posted November 9, 2012 Share Posted November 9, 2012 shuffle does not return the shuffled array. It modifies the array passed as a parameter. $maximum_integer = strip_tags(trim($_REQUEST['maximum_integer'])); $range = range(0,$maximum_integer); shuffle($range); $random_range_imploded = implode(', ', $range); print $random_range_imploded; Quote Link to comment https://forums.phpfreaks.com/topic/270488-how-to-shuffle-an-array-then-implode-it/#findComment-1391222 Share on other sites More sharing options...
CallMeDiz Posted November 9, 2012 Author Share Posted November 9, 2012 Thanks David! Quote Link to comment https://forums.phpfreaks.com/topic/270488-how-to-shuffle-an-array-then-implode-it/#findComment-1391224 Share on other sites More sharing options...
JamesThePanda Posted November 9, 2012 Share Posted November 9, 2012 it looks like its returning a boolean. Quote Link to comment https://forums.phpfreaks.com/topic/270488-how-to-shuffle-an-array-then-implode-it/#findComment-1391227 Share on other sites More sharing options...
Pikachu2000 Posted November 9, 2012 Share Posted November 9, 2012 Start var_dump()ing things at various points and see where the input/output becomes something other than what it should be. Quote Link to comment https://forums.phpfreaks.com/topic/270488-how-to-shuffle-an-array-then-implode-it/#findComment-1391293 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.