title: Search a number in string formatted array in PHP?
body: <p>My array looks like this:</p>
  
  <pre><code>array( '0|500|0.50', '501|1000|0.75' );
  </code></pre>
  
  <p>I am trying to run a search to get the KEY which has the searched value. </p>
  
  <p>I made this function to search:</p>
  
  <pre><code>function cu_array_search($str,$array){
      foreach($array as $key =&gt; $value) {
          if(strstr($str,$value)) {
              return true;
          } else {
              return false;
          }
      }
  }
  </code></pre>
  
  <p>and using it like this when checking:</p>
  
  <pre><code>if (cu_array_search(500,$array) {
  </code></pre>
  
  <p>but it never return true, despite that 500 exists in first key in array .</p>
  
  <p>How to resolve this?</p>
  
  <p>Thanks </p>