fork download
  1. <?php
  2. $choices = array("eggs" => "Eggs Benedict",
  3. "toast" => "Butterd Toast With Jam",
  4. "coffee" => "Piping Hot Coffee");
  5. foreach ($choices as $key => $choice){
  6. echo "<input type='radio' name='food' value='$key' /> $choice \n";
  7. }
  8. if (! array_key_exists($_POST['food'], $choices)){
  9. echo "you must select a valid choice.";}?>
Success #stdin #stdout #stderr 0.02s 25880KB
stdin
1
2
10
42
11
stdout
<input type='radio' name='food' value='eggs' /> Eggs Benedict 
<input type='radio' name='food' value='toast' /> Butterd Toast With Jam 
<input type='radio' name='food' value='coffee' /> Piping Hot Coffee 
you must select a valid choice.
stderr
PHP Notice:  Undefined index: food in /home/Gf5Kz8/prog.php on line 8