PHP code example of traderinteractive / filter-arrays

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

    

traderinteractive / filter-arrays example snippets


$input = ['foo' => 1, 'bar' => 2];
$keyMap = ['FOO_VALUE' => 'foo', 'BAR_VALUE' => 'bar'];
$result = \TraderInteractive\Filter\Arrays::copy($input, $keyMap);
assert($result === ['FOO_VALUE' => 1, 'BAR_VALUE' => 2]);

$input = [
    ['foo' => 1, 'bar' => 2],
    ['foo' => 3, 'bar' => 4],
];
$keyMap = ['FOO_VALUE' => 'foo', 'BAR_VALUE' => 'bar'];
$result = \TraderInteractive\Filter\Arrays::copyEach($input, $keyMap);
assert($result === [['FOO_VALUE' => 1, 'BAR_VALUE' => 2], ['FOO_VALUE' => 3, 'BAR_VALUE' => 4]]);

\TraderInteractive\Filter\Arrays::in($value, ['a', 'b', 'c']);

\TraderInteractive\Filter\Arrays::filter($value, 3, 3);

$value = \TraderInteractive\Filter\Arrays::flatten([[1, 2], [3, [4, 5]]]);
assert($value === [1, 2, 3, 4, 5]);

$value = \TraderInteractive\Filter\Arrays::implode(['lastname', 'email', 'phone'], ',');
assert($value === 'lastname,email,phone');

$value = \TraderInteractive\Filter\Arrays::pad([1, 2], 5, 0, \TraderInteractive\Filter\Arrays::ARRAY_PAD_FRONT);
assert($value === [0, 0, 0, 1, 2]);

$value = \TraderInteractive\Filter\Arrays::unique(['foo', 'bar', 'foo']);
assert($value === ['foo', 'bar']);