Skip to content

Commit

Permalink
Optimized hash extract of {n}.field for PHP 5.5+
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Sep 7, 2014
1 parent 1fa7a93 commit 0a1624f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Utility/Hash.php
Expand Up @@ -114,6 +114,9 @@ public static function extract(array $data, $path) {
}

if (strpos($path, '[') === false) {
if (function_exists('array_column') && preg_match('|^\{n\}\.(\w+)$|', $path, $matches)) {
return array_column($data, $matches[1]);
}
$tokens = explode('.', $path);
} else {
$tokens = String::tokenize($path, '.', '[', ']');
Expand Down

0 comments on commit 0a1624f

Please sign in to comment.