diff options
| author | Andreas Fischer <bantu@phpbb.com> | 2010-12-28 22:40:09 +0100 |
|---|---|---|
| committer | Andreas Fischer <bantu@phpbb.com> | 2010-12-28 22:40:09 +0100 |
| commit | 6e51e52f0c0f34a5dea8e3e1730de039ed5895e6 (patch) | |
| tree | 77a05c95078c7f86bfd1c5ae3780788198694e0e /phpBB/includes/utf/utf_tools.php | |
| parent | 90ccdb4dad6521fe0431ab1e9373c5821156bc46 (diff) | |
| parent | 6b4d0a254218e8d40151ca1bdff8c439f89502e9 (diff) | |
| download | forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.tar forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.tar.gz forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.tar.bz2 forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.tar.xz forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.zip | |
Merge branch 'ticket/igorw/9574' into develop
* ticket/igorw/9574:
[ticket/9574] Add pcre_utf8_support() function
[ticket/9574] Remove conditional PHP<5.2 code
[ticket/9574] Drop fallback implementations
Diffstat (limited to 'phpBB/includes/utf/utf_tools.php')
| -rw-r--r-- | phpBB/includes/utf/utf_tools.php | 72 |
1 files changed, 14 insertions, 58 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 2247315e04..cac5b4e744 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -109,70 +109,26 @@ if (extension_loaded('mbstring')) /** * UTF-8 aware alternative to strrpos * Find position of last occurrence of a char in a string - * - * Notes: - * - offset for mb_strrpos was added in 5.2.0, we emulate if it is lower */ - if (version_compare(PHP_VERSION, '5.2.0', '>=')) + /** + * UTF-8 aware alternative to strrpos + * @ignore + */ + function utf8_strrpos($str, $needle, $offset = null) { - /** - * UTF-8 aware alternative to strrpos - * @ignore - */ - function utf8_strrpos($str, $needle, $offset = null) + // Emulate behaviour of strrpos rather than raising warning + if (empty($str)) { - // Emulate behaviour of strrpos rather than raising warning - if (empty($str)) - { - return false; - } + return false; + } - if (is_null($offset)) - { - return mb_strrpos($str, $needle); - } - else - { - return mb_strrpos($str, $needle, $offset); - } + if (is_null($offset)) + { + return mb_strrpos($str, $needle); } - } - else - { - /** - * UTF-8 aware alternative to strrpos - * @ignore - */ - function utf8_strrpos($str, $needle, $offset = null) + else { - // offset for mb_strrpos was added in 5.2.0 - if (is_null($offset)) - { - // Emulate behaviour of strrpos rather than raising warning - if (empty($str)) - { - return false; - } - - return mb_strrpos($str, $needle); - } - else - { - if (!is_int($offset)) - { - trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_ERROR); - return false; - } - - $str = mb_substr($str, $offset); - - if (false !== ($pos = mb_strrpos($str, $needle))) - { - return $pos + $offset; - } - - return false; - } + return mb_strrpos($str, $needle, $offset); } } |
