title: equivalent of JavaScript findIndex() in PHP
body: <p>This is how I am retrieving items from an array in JavaScript, it works fine:</p>
  
  <pre><code>function getLibItemByName(name){
      var index = json.library.findIndex(p =&gt; p.name == name);
      return json.library[index];
  }
  </code></pre>
  
  <p>my array is like:</p>
  
  <pre><code>[
      {
          "name": "item1"
      },
      {
          "name": "item2"
      },
      ...
  ]
  </code></pre>
  
  <p>Now I am wondering how I can do the same in PHP?</p>
  
  <p><strong>Update</strong>: I came up with this that is working for now</p>
  
  <pre><code>function getLibItemByName($name){
      global $json;
      foreach($json['library'] as $key =&gt; $val){
          if($name === $val['name']){
              return $json['library'][$key];
          }
      }
      return false;
  }
  </code></pre>