Last active
August 14, 2017 06:30
-
-
Save duan-li/cc94c7568757099921c6d98e5eea3129 to your computer and use it in GitHub Desktop.
laravel array help function array_get
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://github.com/rappasoft/laravel-helpers | |
$arr = [ | |
'a' => [ | |
'b' => 'b1', | |
'c' => 'c1', | |
], | |
'd' => [ | |
'd1', | |
'd2', | |
'd3', | |
] | |
]; | |
echo array_get($arr, 'a.b', 'not exist'); // output b1 | |
echo array_get($arr, 'a.c', 'not exist'); // output c1 | |
echo array_get($arr, 'd.0', 'not exist'); // output d1 | |
echo array_get($arr, 'd.1', 'not exist'); // output d2 | |
echo array_get($arr, 'd.2', 'not exist'); // output d3 | |
die; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment