Giter Club home page Giter Club logo

arr's Introduction

A PHP collection of utilities to manipulate arrays. Compatible with, PHP 7 and Php 7.1.

Author Latest Version on Packagist Total Downloads Software License

Master

Build Status Coverage Status Quality Score

Develop

Build Status Coverage Status Quality Score

Why?

Installation

Via Composer

$ composer require narrowspark/arr

or

"require": {
    "narrowspark/arr": "~2.0"
}

Arr

All methods listed under "Arr".

use Narrowspark\Arr\Arr;

// Returns a new array with the added key and value;
// ['foo' => bar, 'arr' => 'narrowsaprk']
Arr::set(['foo' => bar], 'arr', 'narrowspark');

set

Set an array item to a given value using "dot" notation. If no key is given to the method, the entire array will be replaced.

    $arr = Arr::set(['foo' => 'bar'], 'arr', 'narrowspark'); // ['foo' => 'bar', 'arr' => 'narrowspark']

get

Get an item from an array using "dot" notation. If key dont exist, you get a default value back.

    $arr = Arr::get(['foo' => 'bar'], 'foo', 'narrowspark'); // bar

add

Add an element to the array at a specific location using the "dot" notation.

    $arr = Arr::add(['foo' => 'bar'], 'foo', 'narrowspark'); // ['foo' => ['bar', 'narrowspark']]

has

Check if an item exists in an array using "dot" notation.

    $arr = Arr::has(['foo' => 'bar'], 'foo'); // true

update

Updates data at the given path.

    $increment = function ($value) {
        return $value + 1;
    };

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

forget

Remove one or many array items from a given array using "dot" notation.

    $arr = ['foo' => 'bar']

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

    $arr; // []

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

From the project directory, tests can be ran using phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

arr's People

Contributors

prisis avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

arr's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.