PHP code example of narrowspark / arr

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

    

narrowspark / arr example snippets

 php
use Narrowspark\Arr\Arr;

// Returns a new array with the added key and value;
// ['foo' => bar, 'arr' => 'narrowsaprk']
Arr::set(['foo' => bar], 'arr', 'narrowspark');
 php
    $arr = Arr::set(['foo' => 'bar'], 'arr', 'narrowspark'); // ['foo' => 'bar', 'arr' => 'narrowspark']
 php
    $arr = Arr::get(['foo' => 'bar'], 'foo', 'narrowspark'); // bar
 php
    $arr = Arr::add(['foo' => 'bar'], 'foo', 'narrowspark'); // ['foo' => ['bar', 'narrowspark']]
 php
    $arr = Arr::has(['foo' => 'bar'], 'foo'); // true
 php
    $increment = function ($value) {
        return $value + 1;
    };

    $arr = Arr::update(['foo' => 1], $increment); // ['foo' => 2]
 php
    $arr = ['foo' => 'bar']

    Arr::forget($arr, 'foo');

    $arr; // []