PHP 8.5.0 Alpha 4 available for testing

Voting

: two minus zero?
(Example: nine)

The Note You're Voting On

Anonymous
11 years ago
Yet another single-line mb_trim() function

<?php
function mb_trim($string, $trim_chars = '\s'){
return
preg_replace('/^['.$trim_chars.']*(?U)(.*)['.$trim_chars.']*$/u', '\\1',$string);
}
$string = ' "some text." ';
echo
mb_trim($string, '\s".');
//some text
?>

<< Back to user notes page

To Top