Longhorn PHP 2025 - Call For Papers

Voting

: one minus one?
(Example: nine)

The Note You're Voting On

chuayw2000 at hotmail dot com
19 years ago
I don't know if this function is multibyte safe but I've written a function that will do the same in multibyte mode.

<?php
//Check to see if it exists in case PHP has this function later
if (!function_exists("mb_substr_replace")){
//Same parameters as substr_replace with the extra encoding parameter.
function mb_substr_replace($string,$replacement,$start,$length=null,$encoding = null){
if (
$encoding == null){
if (
$length == null){
return
mb_substr($string,0,$start).$replacement;
}
else{
return
mb_substr($string,0,$start).$replacement.mb_substr($string,$start + $length);
}
}
else{
if (
$length == null){
return
mb_substr($string,0,$start,$encoding).$replacement;
}
else{
return
mb_substr($string,0,$start,$encoding). $replacement. mb_substr($string,$start + $length,mb_strlen($string,$encoding),$encoding);
}
}
}
}
?>

<< Back to user notes page

To Top