Permalink
Browse files

small refactor

  • Loading branch information...
1 parent a92f491 commit 97883c232405e47a6cdd23c80c9caf9793ae98a3 @jaz303 committed May 4, 2009
Showing with 4 additions and 8 deletions.
  1. +2 −4 helpers.php
  2. +2 −4 src/array_path.php
View
6 helpers.php
@@ -51,8 +51,7 @@ function is_enumerable($thing) {
function array_path($array, $path, $default = null) {
$path = explode('.', $path);
- while (count($path)) {
- $key = array_shift($path);
+ while ($key = array_shift($path)) {
if (!isset($array[$key])) return $default;
$array = $array[$key];
}
@@ -62,8 +61,7 @@ function array_path($array, $path, $default = null) {
function array_path_unset(&$array, $path) {
$tmp = & $array;
$path = explode('.', $path);
- while (count($path) > 1) {
- $key = array_shift($path);
+ while ($key = array_shift($path)) {
if (!isset($tmp[$key])) return;
$tmp = & $tmp[$key];
}
View
6 src/array_path.php
@@ -4,8 +4,7 @@
function array_path($array, $path, $default = null) {
$path = explode('.', $path);
- while (count($path)) {
- $key = array_shift($path);
+ while ($key = array_shift($path)) {
if (!isset($array[$key])) return $default;
$array = $array[$key];
}
@@ -15,8 +14,7 @@ function array_path($array, $path, $default = null) {
function array_path_unset(&$array, $path) {
$tmp = & $array;
$path = explode('.', $path);
- while (count($path) > 1) {
- $key = array_shift($path);
+ while ($key = array_shift($path)) {
if (!isset($tmp[$key])) return;
$tmp = & $tmp[$key];
}

0 comments on commit 97883c2

Please sign in to comment.