title: PHP / mySQL - in_array and Get Result
body: <p>I have an array like below and that array refers to another data on my db,</p>
  
  <pre><code>    Array
  (
      [0] =&gt; 4
      [1] =&gt; 1
      [2] =&gt; 15
      [3] =&gt; 1
      [4] =&gt; 1
  )
  </code></pre>
  
  <p>how do I want to select value no 1, and get the most top value from table that has <code>value=1</code>?</p>
  
  <p>I use <code>in_array(1,$array)</code> but it does not output anything. Below are my coding;</p>
  
  <pre><code>$sql = " Select * FROM table_name WHERE staff_id='".$_SESSION['staff_id']."' ORDER BY table_name DESC ";
  $result=mysqli_query($conn,$sql) or die(mysqli_error());
  $leave_id= array();
  while($row_permohonan=mysqli_fetch_assoc($result_permohonan))
  {  
      $leave_available = $row_permohonan['leave'];
      $leave_id[] = $row_permohonan['leave_id'];
  } mysqli_free_result($result_permohonan);
  
  //echo '&lt;pre&gt;'; print_r($leave_id); echo '&lt;/pre&gt;';  
  if(in_array(1,$leave_id)){
      echo $leave_available .'/'.$row['total_leave'];
  }
  </code></pre>