Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
28c6ac93
Commit
28c6ac93
authored
Aug 02, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scrap Arr::dot and put dot notation support in Arr::get.
parent
db5c61d5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
24 deletions
+2
-24
arr.php
system/arr.php
+2
-24
No files found.
system/arr.php
View file @
28c6ac93
...
@@ -5,7 +5,8 @@ class Arr {
...
@@ -5,7 +5,8 @@ class Arr {
/**
/**
* Get an item from an array.
* Get an item from an array.
*
*
* If the specified key is null, the entire array will be returned.
* If the specified key is null, the entire array will be returned. The array may
* also be accessed using JavaScript "dot" style notation.
*
*
* @param array $array
* @param array $array
* @param string $key
* @param string $key
...
@@ -19,29 +20,6 @@ class Arr {
...
@@ -19,29 +20,6 @@ class Arr {
return
$array
;
return
$array
;
}
}
if
(
array_key_exists
(
$key
,
$array
))
{
return
$array
[
$key
];
}
return
is_callable
(
$default
)
?
call_user_func
(
$default
)
:
$default
;
}
/**
* Get an item from an array using JavaScript style "dot" notation.
*
* @param array $array
* @param string $key
* @param mixed $default
* @return mixed
*/
public
static
function
dot
(
$array
,
$key
,
$default
=
null
)
{
if
(
is_null
(
$key
))
{
return
$array
;
}
foreach
(
explode
(
'.'
,
$key
)
as
$segment
)
foreach
(
explode
(
'.'
,
$key
)
as
$segment
)
{
{
if
(
!
isset
(
$array
[
$segment
]))
if
(
!
isset
(
$array
[
$segment
]))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment