Files
sourceforge-ossez/oss/joomla/trunk/libraries/phputf8/substr_replace.php
T
YuCheng Hu 1cf84f1313 添加到 trunk
+YUCHENG HU+

git-svn-id: https://svn.code.sf.net/p/hawebs/svn@215 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
2010-06-12 20:06:48 +00:00

25 lines
680 B
PHP

<?php
/**
* @version $Id: substr_replace.php 10381 2008-06-01 03:35:53Z pasamio $
* @package utf8
* @subpackage strings
*/
//---------------------------------------------------------------
/**
* UTF-8 aware substr_replace.
* Note: requires utf8_substr to be loaded
* @see http://www.php.net/substr_replace
* @see utf8_strlen
* @see utf8_substr
*/
function utf8_substr_replace($str, $repl, $start , $length = NULL ) {
preg_match_all('/./us', $str, $ar);
preg_match_all('/./us', $repl, $rar);
if( $length === NULL ) {
$length = utf8_strlen($str);
}
array_splice( $ar[0], $start, $length, $rar[0] );
return join('',$ar[0]);
}