note 99482 deleted from ref.mbstring by cmb

From: Date: Sat, 20 Aug 2016 15:25:10 +0000
Subject: note 99482 deleted from ref.mbstring by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206345@lists.php.net to get a copy of this message
Note Submitter: phpnet at rcpt dot at ---- <?php /** * Multibyte safe version of trim() * Always strips whitespace characters (those equal to \s) * * @author Peter Johnson * @email phpnet@rcpt.at * @param $string The string to trim * @param $chars Optional list of chars to remove from the string ( as per trim() ) * @param $chars_array Optional array of preg_quote'd chars to be removed * @return string */ public static function mb_trim( $string, $chars = "", $chars_array = array() ) { for( $x=0; $x<iconv_strlen( $chars ); $x++ ) $chars_array[] = preg_quote( iconv_substr( $chars, $x, 1 ) ); $encoded_char_list = implode( "|", array_merge( array( "\s","\t","\n","\r", "\0", "\x0B" ), $chars_array ) ); $string = mb_ereg_replace( "^($encoded_char_list)*", "", $string ); $string = mb_ereg_replace( "($encoded_char_list)*$", "", $string ); return $string; } ?>

« previous php.notes (#206345) next »