我有二维数组,我想在第二个数组的随机数上替换第二个二维数组
Array
(
[1] => Array
(
[0] => 1
[1] => 3
[2] => 5
[3] => 500
[4] => 600
[5] => 700
)
[2] => Array
(
[0] => 2
[1] => 4
[2] => 6
)
)
我想得到
Array (
[1] => 5 (<- random from first array)
[2] => 6 (<- random from second array)
)
我试着做:
foreach($variables as $key => $val) {
$variables = str_replace($val, $val[array_rand($val)], $variables);
}
为什么它不起作用?