This repository was archived by the owner on Dec 8, 2022. It is now read-only.
forked from mako-framework/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
06_learn_more__00_array_helper
Marco Montalbano edited this page Jul 31, 2017
·
1 revision
The array helper contains methods that can be useful when working with arrays.
The get method returns a value from an array using "dot notation".
$array = array('foo' => array('bar' => 'baz'));
$bar = Arr::get($array, 'foo.bar');
// You can also specify a default value if the key doesn't exist
$baz = Arr::get($array, 'foo.baz', 'nope');
The set method sets an array value using "dot notation".
Arr::set($array, 'foo.baz', 'hello world');
The delete method deletes an array value using "dot notation".
Arr::delete($array, 'foo.bar');
The random method returns a random array value.
Arr::random(array('green', 'blue', 'red', 'orange'));
The isAssoc method returns TRUE if the array is associative and FALSE if not.
// $assoc will be set to FALSE
$assoc = Arr::isAssoc(array(1, 2, 3));
// $assoc will be set to TRUE
$assoc = Arr::isAssoc(array('one' => 1, 'two' => 2, 'three' => 3))
The pluck method returns the values from a single column of the input array, identified by the key.
$fruits = array
(
array('name' => 'apple', 'color' => 'green'),
array('name' => 'banana', 'color' => 'yellow');
);
$colors = Arr::pluck($fruits, 'color');
- Getting started: Installation
- Getting started: Configuration
- Getting started: Error handling
- Getting started: Constants
- Getting started: Coding standards
- Controllers: Controllers
- Controllers: Request
- Controllers: Response
- Databases: Basics
- Databases: Query builder
- Databases: Orm
- Databases: Migrations
- Command line: Basics
- Command line: Custom tasks
- Packages: Basics
- Packages: Composer packages
- Learn more: Array helper
- Learn more: Asset manager
- Learn more: Autoloading
- Learn more: Caching
- Learn more: Cookies
- Learn more: Events
- Learn more: File helper
- Learn more: Html helper
- Learn more: Internationalization
- Learn more: Logging
- Learn more: Number helper
- Learn more: Pagination
- Learn more: Redis client
- Learn more: Rest client
- Learn more: Security helpers
- Learn more: Sessions
- Learn more: String helper
- Learn more: Url helper
- Learn more: Uuid helper
- Learn more: Validation
- Learn more: Views