Merge branch '3.1/release/3.1.4' into 3.1/master
[kohana-core.git] / utf8 / strrpos.php
blob0115583fb647895e4ebe9827ec918209132f1db6
1 <?php defined('SYSPATH') or die('No direct script access.');
2 /**
3 * UTF8::strrpos
5 * @package Kohana
6 * @author Kohana Team
7 * @copyright (c) 2007-2011 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 (UTF8::is_ascii($str) AND UTF8::is_ascii($search))
16 return strrpos($str, $search, $offset);
18 if ($offset == 0)
20 $array = explode($search, $str, -1);
21 return isset($array[0]) ? UTF8::strlen(implode($search, $array)) : FALSE;
24 $str = UTF8::substr($str, $offset);
25 $pos = UTF8::strrpos($str, $search);
26 return ($pos === FALSE) ? FALSE : ($pos + $offset);