PHP code example of jstewmc / in-arrays

1. Go to this page and download the library: Download jstewmc/in-arrays 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/ */

    

jstewmc / in-arrays example snippets


use Jstewmc\InArrays\In;

$arrays = [
    'foo' => ['foo', 'bar', 'baz'],
    'bar' => ['foo', 'bar', 'baz']
];

$service = new In($arrays);

$service('foo', 'foo');  // returns true
$service('bar', 'foo');  // returns true
$service('bar', 'qux');  // returns false (value "qux" does not exist)
$service('baz', 'foo');  // returns false (array "baz" does not exist)

use Jstewmc\InArrays\In;

// note the lower-case key and value
$service = new In(['foo' => ['foo']);

$service('foo', 'foo');  // returns true
$service('FOO', 'foo');  // returns false (keys are case-sensitive)
$service('bar', 'FOO');  // returns false (values are case-sensitive)