fork download
  1. <?php
  2.  
  3. $products = [
  4. 0 => [
  5. 'name' => 'Basic Plan',
  6. 'cost' => 10,
  7. ],
  8. 1 => [
  9. 'name' => 'Standard Plan',
  10. 'cost' => 10,
  11. ],
  12. 2 => [
  13. 'name' => 'Basic Plan',
  14. 'cost' => 10,
  15. ],
  16. ];
  17.  
  18. $_POST['plan'] = 1;
  19.  
  20. $selected = $products[$_POST['plan']];
  21. echo "You chose,\n Our {$products[$_POST['plan']]['name']} and that costs \${$products[$_POST['plan']]['cost']}";
Success #stdin #stdout 0.01s 82560KB
stdin
Standard input is empty
stdout
You chose,
 Our Standard Plan and that costs $10