FIREBALL5 Posted September 21, 2008 Share Posted September 21, 2008 Is there any way to shuffle two arrays by the same pattern? Example: $a = array('a','b','c','d'); $b = array('a','b','c','d'); shuffle both by same pattern, and: $a = array('b','d','a','c'); $b = array('b','d','a','c'); Quote Link to comment Share on other sites More sharing options...
sasa Posted September 22, 2008 Share Posted September 22, 2008 try <?php $a = array('a','b','c','d'); $b = array('a','b','c','d'); $tmp = range(1, 4); shuffle($tmp); array_multisort($tmp, $a, $b); print_r($a); print_r($b); ?> Quote Link to comment Share on other sites More sharing options...
FIREBALL5 Posted September 22, 2008 Author Share Posted September 22, 2008 Wow, I didn't know about that. Thank you so much! Btw, I don't know how to add "[solved]" to my topic, but it's solved now, my thanks to sasa. I hope others will benefit from this topic, and his genius. Quote Link to comment 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.