| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: core.php 10381 2008-06-01 03:35:53Z pasamio $ 4 * @package utf8 5 * @subpackage strings 6 */ 7 8 /** 9 * Define UTF8_CORE as required 10 */ 11 if ( !defined('UTF8_CORE') ) { 12 define('UTF8_CORE',TRUE); 13 } 14 15 //-------------------------------------------------------------------- 16 /** 17 * Assumes mbstring internal encoding is set to UTF-8 18 * Wrapper around mb_strpos 19 * Find position of first occurrence of a string 20 * @param string haystack 21 * @param string needle (you should validate this with utf8_is_valid) 22 * @param integer offset in characters (from left) 23 * @return mixed integer position or FALSE on failure 24 * @package utf8 25 * @subpackage strings 26 */ 27 function utf8_strpos($str, $search, $offset = FALSE){ 28 if(strlen($str) && strlen($search)) { 29 if ( $offset === FALSE ) { 30 return mb_strpos($str, $search); 31 } else { 32 return mb_strpos($str, $search, $offset); 33 } 34 } else return FALSE; 35 } 36 37 //-------------------------------------------------------------------- 38 /** 39 * Assumes mbstring internal encoding is set to UTF-8 40 * Wrapper around mb_strrpos 41 * Find position of last occurrence of a char in a string 42 * @param string haystack 43 * @param string needle (you should validate this with utf8_is_valid) 44 * @param integer (optional) offset (from left) 45 * @return mixed integer position or FALSE on failure 46 * @package utf8 47 * @subpackage strings 48 */ 49 function utf8_strrpos($str, $search, $offset = FALSE){ 50 if ( $offset === FALSE ) { 51 # Emulate behaviour of strrpos rather than raising warning 52 if ( empty($str) ) { 53 return FALSE; 54 } 55 return mb_strrpos($str, $search); 56 } else { 57 if ( !is_int($offset) ) { 58 trigger_error('utf8_strrpos expects parameter 3 to be long',E_USER_WARNING); 59 return FALSE; 60 } 61 62 $str = mb_substr($str, $offset); 63 64 if ( FALSE !== ( $pos = mb_strrpos($str, $search) ) ) { 65 return $pos + $offset; 66 } 67 68 return FALSE; 69 } 70 } 71 72 //-------------------------------------------------------------------- 73 /** 74 * Assumes mbstring internal encoding is set to UTF-8 75 * Wrapper around mb_substr 76 * Return part of a string given character offset (and optionally length) 77 * @param string 78 * @param integer number of UTF-8 characters offset (from left) 79 * @param integer (optional) length in UTF-8 characters from offset 80 * @return mixed string or FALSE if failure 81 * @package utf8 82 * @subpackage strings 83 */ 84 function utf8_substr($str, $offset, $length = FALSE){ 85 if ( $length === FALSE ) { 86 return mb_substr($str, $offset); 87 } else { 88 return mb_substr($str, $offset, $length); 89 } 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |