title: unable to change input data and db query result to array for pattern recognition
body: <p>I'm unable to change an input string($prima = $_POST['id'];) and a db query result ($systemuser['id'];) into an array
  which will be used for pattern matching using one single character at a time and then trying to
  find a match in the database "id" row that is queried. The point is to use two-third of an id(supposedly incomplete id of a user of a system) to query and find the complete id. Please see my code. I'd appreciate some help. Thanks 
  I'm getting "undefined offset:0 through 9" error.</p>
  
  <pre><code>&lt;?php
  session_start();
  include_once('server.php');
  
  $error = false;
  $gat = "";
  $get = "";
  $rt1 = "";
  $rt2 = "";
  $rt3 = "";
  $rt4 = "";
  $rt5 = "";
  $rt6 = "";
  $rt7 = "";
  $rt8 = "";
  $rt9 = "";
  $rt0 = "";
  
  
  if(isset($_POST['btn-login'])){
  
  $firstname = $_POST['firstname'];
  $firstname = trim($firstname);
  $firstname = trim($_POST['firstname']);
  $firstname = htmlspecialchars(strip_tags($firstname));  
  
  $lastname = $_POST['lastname'];
  $lastname = trim($lastname);
  $lastname = trim($_POST['lastname']);
  $lastname = htmlspecialchars(strip_tags($lastname));
  
  $id = $_POST['id'];
  $id = trim($id);
  $id = trim($_POST['id']);
  $id = htmlspecialchars(strip_tags($id));
  
  $gender = $_POST['gender'];
  
  
     if(!$error) {
      //search data if no errors 
  
      $query = "select * from subscribers";
      $conditions = array();
  
      if(! empty($firstname)){
          $conditions[] = "firstname='$firstname'";
      }
  
      if(! empty($lastname)){
          $conditions[] = "lastname='$lastname'";
      }
  
      if(! empty($gender)){
          $conditions[] = "gender='$gender'";
      }
  
  
     $sql = $query;
      if(count($conditions) &gt; 0){
          $sql .= " WHERE " . implode(' AND ', $conditions);
      }
  
  
      $result = mysqli_query($conn, $sql);
  
  
      while($systemuser = mysqli_fetch_array($result, MYSQLI_ASSOC)){
  
        $systemuser['id'];
        $gat = $systemuser['id'];
  
      }       
  
  
    //convert user input to array
      $prima = $_POST['id'];
      $prima = array();
      $rt1 = $prima[0];
      $rt2 = $prima[1];
      $rt3 = $prima[2];
      $rt4 = $prima[3];
      $rt5 = $prima[4];
      $rt6 = $prima[5];
      $rt7 = $prima[6];
      $rt8 = $prima[7];
      $rt9 = $prima[8];
      $rt0 = $prima[9];
  
      //retrieve and convert db data into array
      $gat = array(); 
  
  
  
  
      foreach( $gat as $get ){ 
  
      $rt1 = $prima[0];      
      if (preg_match("/[$rt1]+/", $gat));{
          $get += 1;
       }
  
      $rt2 = $prima[1];       
      if (preg_match("/[$rt2]+/", $gat)){ 
          $get += 1;
      }
  
      $rt3 = $prima[2];
      if (preg_match("/[$rt3]+/", $gat)){ 
          $get += 1;
      }
  
      $rt4 = $prima[3];
      if (preg_match("/[$rt4]+/", $gat)){ 
          $get += 1;
      }
  
      $rt5 = $prima[4];
      if (preg_match("/[$rt5]+/", $gat)){ 
          $get += 1;
      }
  
      $rt6 = $prima[5];
      if (preg_match("/[$rt6]+/", $gat)){ 
          $get += 1;
      }
  
      $rt7 = $prima[6];
      if (preg_match("/[$rt7]+/", $gat)){ 
          $get += 1;
      }
  
      $rt8 = $prima[7];
      if (preg_match("/[$rt8]+/", $gat)){ 
          $get += 1;
      }
  
      $rt9 = $prima[8];
      if (preg_match("/[$rt9]+/", $gat)){
          $get += 1;
      }
  
      $rt0 = $prima[9];
      if (preg_match("/[$rt0]+/", $gat)){ 
          $get += 1;
      }
  
      if ($get &gt; 9){
          echo 'match found!';
  
      }
      else{
          echo 'match not found!';
      }
  
  
      }
  
  
  
  
     }
  
  }
  
  ?&gt;
  </code></pre>