Skip to content

Instantly share code, notes, and snippets.

@kiyoto
Created June 15, 2012 00:38
Show Gist options
  • Save kiyoto/2933917 to your computer and use it in GitHub Desktop.
Save kiyoto/2933917 to your computer and use it in GitHub Desktop.
creating random associative arrays
<?php
function random_array(&$current) {
foreach ($current as $k => &$v) {
if ((rand() % 10) / 10 >= 0.68) {
$v = array(0, 'aoiyu', 1337);
random_array($v);
}
}
unset($v);
}
$start = array(0,1,2);
random_array($start);
echo json_encode($start);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment