PHP 8.6.0 Alpha 2 available for testing

Voting

: max(five, six)?
(Example: nine)

The Note You're Voting On

chuayw2000 at hotmail dot com
20 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

AltStyle によって変換されたページ (->オリジナル) /