fork download
  1. <?php
  2. $strokes = array();
  3.  
  4. $_POST = array("h1" => 1, "h2" => 2, "h3" => 3, "h4" => 0);
  5.  
  6. $strokes_keys = array('h1', 'h2', 'h3', 'h4');
  7.  
  8. foreach ($strokes_keys as $stroke) {
  9. if (isset($_POST[$stroke])) {
  10. array_push($strokes, $_POST[$stroke]);
  11. }
  12. }
  13. $counts = count($strokes);
  14.  
  15. var_dump($strokes);
  16. var_dump($counts);
  17.  
  18.  
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
array(4) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  int(0)
}
int(4)