array_rand : array_rand « Data Structure « PHP






array_rand

 
<?php

$states = array("Ohio" => "Columbus", "Iowa" => "Des Moines","Arizona" => "Phoenix");
$randomStates = array_rand($states, 2);
print_r($randomStates);

?>
  
  








Related examples in the same category

1.A Random-Image Script Using array_rand()
2.mixed array_rand ( array arr [, int amount] )