PHP code example of luminovang / array-functions

1. Go to this page and download the library: Download luminovang/array-functions 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/ */

    

luminovang / array-functions example snippets




use function Luminova\Procedural\ArrayFunctions\{
   array_find, 
   array_find_key, 
   array_any, 
   array_all
};

use function Luminova\Procedural\ArrayFunctions\array_find;

$result = array_find([1, 2, 3, 4, 5], fn(int $value) => $value > 3);

echo $result; // Output: 4

$result = array_find_key(['apple', 'banana', 'cherry'], fn(string $value) => $value === 'banana');

echo $result; // Output: 1

$result = array_find_key(
   ['java' => 1, 'php' => 2, 'swift' => 3], 
   fn(int $value, string $key) => str_starts_with($key, 'p')
);

echo $result; // Output: php

$result = array_all([2, 4, 6], fn(int $value) => $value % 2 === 0);
echo $result; // Output: true

$result = array_any([1, 2, 3], fn(int $value) => $value > 2);
echo $result; // Output: true