title: How to use an array as $haystack and $array[$i] (string) as needle in php?
body: <p>The code is:</p>
  
  <pre><code>&lt;?php
  $notes = array("Main/folder/02/12.jpg = twelve",
                 "Main/folder/02/16.jpg = sixteen"
                 );
  $imglist = array( "12.jpg",
                    "13.jpg",
                    "14.jpg",
                    "15.jpg",
                    "16.jpg"
                    );
  for ($i=0;$i&lt;(count($imglist));$i++){
      if(in_array($imglist[$i], $notes)){
          echo $imglist[$i];
          //Get key($notes) and //Cant figure out how to implement this key();
          echo $notes[$key];
      } //if ENDS
  } //for ENDS
  ?&gt;
  </code></pre>
  
  <p>What I need is that for $i=0 and $i=4, if() should return TRUE &amp; do the echoes.</p>
  
  <p>The pseudo-code/logic is:</p>
  
  <ul>
  <li>Iterate through all the $imglist array one by one.</li>
  <li>if the complete $imglist[$i] string is found anywhere in $notes array, get the key/index of that value in $notes, and echo $notes[$key] and $imglist[$i]. OR Echo $notes[$key].</li>
  </ul>
  
  <p>For example the desired output of this for loop should be:</p>
  
  <pre><code>12.jpg Main/folder/02/12.jpg = twelve
  16.jpg Main/folder/02/16.jpg = sixteen
  </code></pre>
  
  <p>The problem is that now this all code is just outputting none. Means that if condition is not returning TRUE ever. Whereas in theory it should return TRUE when $i is 0 &amp; 4. Is my if() condition wrong? Is php not taking $imglist[$i] as a string? Should I use strpos?</p>