issue: Cannot Redeclare mb_str_pad()

This addresses an issue where in PHP 8.3 our declaration of `mb_str_pad()`
conflicts with the native `mb_str_pad()`. This adds a check to see if the
function already exists or not before declaring it.
This commit is contained in:
JediKev
2024-05-14 17:58:37 +00:00
parent b38db3725a
commit fea5e1e043

View File

@@ -1020,14 +1020,16 @@ function mb_wordwrap($string, $width=75, $break="\n", $cut=false) {
return rtrim(preg_replace($search, $replace, $string), $break);
}
// Thanks http://www.php.net/manual/en/ref.mbstring.php#90611
function mb_str_pad($input, $pad_length, $pad_string=" ",
$pad_style=STR_PAD_RIGHT) {
$match = array();
$marks = preg_match_all('/\p{M}/u', $input, $match);
return str_pad($input,
strlen($input)-mb_strwidth($input)+$marks+$pad_length, $pad_string,
$pad_style);
if (!function_exists('mb_str_pad')) {
// Thanks http://www.php.net/manual/en/ref.mbstring.php#90611
function mb_str_pad($input, $pad_length, $pad_string=" ",
$pad_style=STR_PAD_RIGHT) {
$match = array();
$marks = preg_match_all('/\p{M}/u', $input, $match);
return str_pad($input,
strlen($input)-mb_strwidth($input)+$marks+$pad_length, $pad_string,
$pad_style);
}
}
// Enable use of html2text from command line