diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-11-13 18:27:40 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-11-13 18:27:40 +0100 |
commit | 13a4ceedb18ba938d3cd18e2f68707385bc9283a (patch) | |
tree | f787d2b82cd103171f72f7430e14b8bec150c258 /phpBB/phpbb/avatar/manager.php | |
parent | 0ec644532d437e2d915185a5a63424d231d49433 (diff) | |
download | forums-13a4ceedb18ba938d3cd18e2f68707385bc9283a.tar forums-13a4ceedb18ba938d3cd18e2f68707385bc9283a.tar.gz forums-13a4ceedb18ba938d3cd18e2f68707385bc9283a.tar.bz2 forums-13a4ceedb18ba938d3cd18e2f68707385bc9283a.tar.xz forums-13a4ceedb18ba938d3cd18e2f68707385bc9283a.zip |
[ticket/11525] Use foreach instead of array_walk in method clean_row()
This approach is cleaner and probably even faster the previous ways that
included using array_walk() or array_map() and other helper functions
and methods.
PHPBB3-11525
Diffstat (limited to 'phpBB/phpbb/avatar/manager.php')
-rw-r--r-- | phpBB/phpbb/avatar/manager.php | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index 9f6a5fb089..12d7861cdf 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -195,33 +195,19 @@ class manager return self::$default_row; } - $keys = array_keys($row); - $values = array_values($row); - - array_walk($keys, array('\phpbb\avatar\manager', 'strip_prefix'), $prefix); - $row = array_combine($keys, $values); - - if ($prefix == 'group') + $output = array(); + foreach ($row as $key => $value) { - $row['id'] = 'g' . $row['id']; + $key = preg_replace("#^(?:{$prefix}_)#", '', $key); + $output[$key] = $value; } - return $row; - } + if ($prefix === 'group' && isset($output['id'])) + { + $output['id'] = 'g' . $output['id']; + } - /** - * Strip prepending user_ or group_ prefix from key - * - * @param string $key Array key - * @param string $null Parameter is ignored by the function, just required by the array_walk - * @param string $prefix Prefix that should be stripped off from the keys (e.g. user) - * Should not include the trailing underscore - * @return null - */ - static protected function strip_prefix(&$key, $null, $prefix) - { - $regex = ($prefix !== '') ? "#^(?:{$prefix}_)#" : '#^(?:user_|group_)#'; - $key = preg_replace($regex, '', $key); + return $output; } /** |