PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php /*$arr = [ 'A' => ['a1', 'a2', 'a3'], 'B' => ['b1', 'b2', 'b3'], 'C' => ['c1', 'c2', 'c3'], ];*//* $array_id = array(1,2,3,4,5); $array_name = array('a','b','c','d','e'); $array_key = array(100,200,300,400,500); $numbers = range(0, sizeof($array_id)-1); shuffle($numbers); print_r($numbers);echo "<br>"; foreach ($numbers as $number) { $arr = array("user" => array("id" => $array_id[$number], "name" => $array_name[$number], "key" => $array_key[$number])); } echo json_encode($arr);*/ $array_1 = [ ['product_1_1', 300, 100], ['product_1_2', 300, 100], ['product_1_3', 300, 100], ['product_1_4', 300, 100], ['product_1_5', 300, 100], ]; $array_2 = [ ['product_2_1', 300, 250], ['product_2_2', 300, 250], ['product_2_3', 300, 250], ['product_2_4', 300, 250], ['product_2_5', 300, 250], ]; $array_3 = [ ['product_3_1', 300, 500], ['product_3_2', 300, 500], ['product_3_3', 300, 500], ['product_3_4', 300, 500], ['product_3_5', 300, 500], ]; $first = rand(0, floor(count($array_1))); $firstItem = $array_1[$first]; unset($array_1[$first]); $merged = array_merge($array_1, $array_2, $array_3); shuffle($merged); array_unshift($merged, $firstItem); echo"<pre>";print_r($merged);echo"</pre>";
Show:  
Copy Clear