<?php
function mb_trim( $string, $toTrim ) {
if ( '' == $string ) return '';
$arToTrim = mb_str_split( $toTrim );
}
if ( ! count( $arToTrim ) ) return $string;
$arString = mb_str_split( $string );
$changed = true;
while ( $changed ) {
$changed = false;
if ( in_array( $arString[ 0 ], $arToTrim ) ) {
if (0 == count( $arString ) ) return '';
$changed = true;
}
if ( in_array( $arString[ count( $arString ) -1 ], $arToTrim ) ) {
if (0 == count( $arString ) ) return '';
$changed = true;
}
}
}
} else {
trigger_error( 'The function "mb_trim" exists! Pleace check your script(s)!', E_USER_ERROR );
}
function mb_rtrim( $string, $toTrim ) {
if ( '' == $string ) return '';
$arToTrim = mb_str_split( $toTrim );
}
if ( ! count( $arToTrim ) ) return $string;
$arString = mb_str_split( $string );
$changed = true;
while ( $changed ) {
$changed = false;
if ( in_array( $arString[ count( $arString ) -1 ], $arToTrim ) ) {
if (0 == count( $arString ) ) return '';
$changed = true;
}
}
}
} else {
trigger_error( 'The function "mb_rtrim" exists! Pleace check your script(s)!', E_USER_ERROR );
}
function mb_ltrim( $string, $toTrim ) {
if ( '' == $string ) return '';
$arToTrim = mb_str_split( $toTrim );
}
if ( ! count( $arToTrim ) ) return $string;
$arString = mb_str_split( $string );
$changed = true;
while ( $changed ) {
$changed = false;
if ( in_array( $arString[ 0 ], $arToTrim ) ) {
if (0 == count( $arString ) ) return '';
$changed = true;
}
}
}
} else {
trigger_error( 'The function "mb_ltrim" exists! Pleace check your script(s)!', E_USER_ERROR );
}