3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &random_value(&$array, $default=null) { $k = 0; // mt_rand(0, count($array) - 1); if (isset($array[$k])) { return $array[$k]; } else { return $default; } } $companies = array(); $companies[] = array("name" => "Acme Co", "employees"=> array( "John", "Jane" )); $companies[] = array("name" => "Inotech", "employees"=> array( "Bill", "Michael" )); $x = &random_value($companies); $x["employees"][] = "Donald"; var_dump($x, $companies);

preferences:
34.15 ms | 402 KiB | 5 Q