2017 © Pedro Peláez
 

library array_helpers

Array helpers functions based on laravel array helper functions.

image

michaelm/array_helpers

Array helpers functions based on laravel array helper functions.

  • Thursday, July 19, 2018
  • by FvsJ101
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

BASIC ARRAY HELPERS BASED ON LARAVEL

This is just a few basic array helper functions based on the laravel array helper functions., (*1)

Install

Install via composer:, (*2)

1) composer require michaelm/array_helpers 2) Run composer install and do a composer dumpautoload -o to optimise the autoloader., (*3)

Usages

Get, Has, Only, Forget
$user = [
    "name" => "Mike",
    "topics" => [
        "city" => "Pretoria",
        "title" => "Winning"
    ],
    "country" => [
        ["name" => "UK"],
        ["name" => "USA"],
    ]
];

echo array_get($user, 'topics.city', 'Default value');

var_dump(array_has($user, ['name', 'country.0.name']));

$result = array_only($user, ['country', 'topics']);
echo '

',print_r($result,true),'
'; array_forget($user, 'name'); //array_forget($user, ['name', 'topics', 'country.0']); echo '
',print_r($user,true),'
';
First, Where, Last

$users = [ ["name" => "Mike", "score" => 100], ["name" => "Tim", "score" => 110], ["name" => "Ralf", "score" => 120], ]; $user = array_last($users, function ($value, $key) { return array_get($value, 'score') < 110; }); echo '
',print_r($user,true),'
'; $user = array_first($users, function ($value, $key){ return array_get($value, 'score') > 110 ; }, 'default value'); var_dump($user); $result = array_where($users, function ($value, $key) { return array_get($value, 'score') > 100; }); var_dump($result);

Credits

CodeCourse released under the MIT license., (*4)

The Versions

19/07 2018

dev-master

9999999-dev

Array helpers functions based on laravel array helper functions.

  Sources   Download

MIT