PHP code example of oliver-dvorski / array_find

1. Go to this page and download the library: Download oliver-dvorski/array_find library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oliver-dvorski / array_find example snippets


$people = [
  ['name' => 'John', 'age' => 20],
  ['name' => 'Jane', 'age' => 21],
  ['name' => 'Jack', 'age' => 22],
];

// Returns ['name' => 'Jane', 'age' => 21]
$found = array_find($people, fn($item) => $item['name'] === 'Jane');