lundi 26 octobre 2015

PHP: array_rand arrays

I'm begginer and i have a problem. I have this array:

$nonTerminals = array("S","A","B");
$grammar = array(
"$nonTerminals[0]" => "aA",
"$nonTerminals[1]" => array("aA","bB"),
"$nonTerminals[2]" => array("bB","b")
);

and I use this for random values:

$rand_keys = array_rand($grammar, 2);
echo $grammar[$rand_keys[0]] . "\n";

but this is wrong, because it's give me some errors. Can someone help me with this ?




Aucun commentaire:

Enregistrer un commentaire