나는 사람들을 짝 지어주는 추첨을 만들고있다. 그래서 어떤 아이템도 같은 장소에서 끝나지 않는 배열에서 문자열을 섞는 방법을 원합니다. (당신은 자신과 짝을 지을 수 없습니다)무작위 셔플?
public function shuffleSantas(){
$query = $this->db->get('person');
$givers = array();
$recievers = array();
foreach($query->result() as $row):
$givers[] = $row->name;
//here i want a random order, but no name can be on the same place as in $givers!
$recievers[] = '';
endforeach;
어쩌면 1 개의 큰 배열을 셔플()하고 반으로 분할 할 수 있습니까? –
['array_rand()'] (http://www.php.net/array_rand)를 살펴볼 수 있습니다. – binaryLV