Merge branch 'maint/7.0'
[ninja.git] / system / core / utf8 / strrpos.php
blob1ac8f9c8d404968d22291fec252c0a86185eb75c
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3 * utf8::strrpos
5 * @package Core
6 * @author Kohana Team
7 * @copyright (c) 2007 Kohana Team
8 * @copyright (c) 2005 Harry Fuecks
9 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
11 function _strrpos($str, $search, $offset = 0)
13 $offset = (int) $offset;
15 if (SERVER_UTF8)
16 return mb_strrpos($str, $search, $offset);
18 if (utf8::is_ascii($str) AND utf8::is_ascii($search))
19 return strrpos($str, $search, $offset);
21 if ($offset == 0)
23 $array = explode($search, $str, -1);
24 return isset($array[0]) ? utf8::strlen(implode($search, $array)) : FALSE;
27 $str = utf8::substr($str, $offset);
28 $pos = utf8::strrpos($str, $search);
29 return ($pos === FALSE) ? FALSE : $pos + $offset;