Advertisement
fahmihilmansyah

array kosong

Apr 9th, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2. if ($_POST) {
  3.     $chk1 = $_POST['chkabc1'];
  4.     $chk2 = $_POST['chkabc2'];
  5.     $chk3 = $_POST['chkabc3'];
  6.     for ($i = 0; $i < count($chk1); $i++) {
  7.         echo "Checkbox 1 value ".$chk1[$i]."<br>";
  8.         echo "Checkbox 2 value ".$chk2[$i]."<br>";
  9.         echo "Checkbox 3 value ".$chk3[$i]."<br>";
  10.      }
  11. }
  12.  
  13.  
  14.  ?>
  15.  
  16.  
  17.  <!DOCTYPE html>
  18.  <html>
  19.  <head>
  20.     <meta charset="utf-8">
  21.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  22.     <title></title>
  23.     <link rel="stylesheet" href="">
  24.  </head>
  25.  <body>
  26.     <form action="http://localhost/coba/arraykosong.php" method="POST" >
  27.         <input type="checkbox" name="chkabc1[]" value="11">
  28.         <input type="checkbox" name="chkabc1[]" value="12">
  29.         <input type="checkbox" name="chkabc1[]" value="13">
  30.         <input type="checkbox" name="chkabc1[]" value="14">
  31. <br>
  32.         <input type="checkbox" name="chkabc2[]" value="21">
  33.         <input type="checkbox" name="chkabc2[]" value="22">
  34.         <input type="checkbox" name="chkabc2[]" value="23">
  35.         <input type="checkbox" name="chkabc2[]" value="24">
  36. <br>
  37.  
  38.         <input type="checkbox" name="chkabc3[]" value="31">
  39.         <input type="checkbox" name="chkabc3[]" value="32">
  40.         <input type="checkbox" name="chkabc3[]" value="33">
  41.         <input type="checkbox" name="chkabc3[]" value="34">
  42. <br>
  43.         <button type="submit">submit</button>
  44.     </form>
  45.  </body>
  46.  </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement