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'); Link to comment https://forums.phpfreaks.com/topic/125226-solved-shuffling-2-arrays-by-the-same-pattern/ 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); ?> Link to comment https://forums.phpfreaks.com/topic/125226-solved-shuffling-2-arrays-by-the-same-pattern/#findComment-647375 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. Link to comment https://forums.phpfreaks.com/topic/125226-solved-shuffling-2-arrays-by-the-same-pattern/#findComment-647398 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.