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.
Notice: Array to string conversion
.var_dump
instead ofecho
so you can print the contents of the arrays.