-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from edcoreweb/master
Added support for PHP 5.3 using Illuminate 4.1.*
- Loading branch information
Showing
5 changed files
with
62 additions
and
28 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Hazzard\Validation; | ||
|
||
use ArrayAccess; | ||
|
||
class Arr | ||
{ | ||
/** | ||
* Get an item from an array using "dot" notation. | ||
* | ||
* @param \ArrayAccess|array $array | ||
* @param string $key | ||
* @param mixed $default | ||
* @return mixed | ||
*/ | ||
public static function get($array, $key, $default = null) | ||
{ | ||
if (is_null($key)) { | ||
return $array; | ||
} | ||
if (isset($array[$key])) { | ||
return $array[$key]; | ||
} | ||
foreach (explode('.', $key) as $segment) { | ||
if ((! is_array($array) || ! array_key_exists($segment, $array)) && | ||
(! $array instanceof ArrayAccess || ! $array->offsetExists($segment))) { | ||
return value($default); | ||
} | ||
$array = $array[$segment]; | ||
} | ||
return $array; | ||
} | ||
} |
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
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
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