Hello! The task is as follows: there are two arrays, one with text, the second with numbers defining the position of this text. For clarity:

$a = array(1,2,3,4,5); $b = array('1a','2b','3c','4d','5e'); 

Array "a" can be changed and depending on this you need to sort the array "b". when mixing can come out like this:

 $a = array(5,2,4,1,3); $b = array('5e','2b','4d','1a','3c'); 

But I can not find a function that would do it "from the box", but for some reason there is a "chuyka" that is similar. For example, now I did this:

 $i = 0; foreach ($b as $value) { $c[$a[$i]] = $b[$a[$i++]]; } 

And, in principle, I got what I wanted, but is the question still an out-of-box solution?

    1 answer 1

    "from the box"

    Arrays have keys:

     $b = array('1a','2b','3c','4d','5e'); uasort($b, function() {return round(rand()*2-1);}); var_dump($b, array_keys($b)); 

    -----

     array(5) { 3 => "4d", 1 => "2b", 0 => "1a", 2 => "3c", 4 => "5e" } // array array(5) { 3, 1, 0, 2, 4 } // array keys, для наглядности 

    If it is important for you to start with one, then prescribe the keys to the array, business

     array(1 => '1a', 2 => '2b',.. 

    chuika

    0_o