The below program is to right trim the string "w;h;" off string "h;" to get "w;". But unexpectedly what I got is "w", not "w;".
<?php
$string="w;h;";
$str="h;";
$nStr=rtrim($string,$str);
echo $nStr.'</br>';
?>
The below program is to right trim the string "w;h;" off string "h;" to get "w;". But unexpectedly what I got is "w", not "w;".
<?php
$string="w;h;";
$str="h;";
$nStr=rtrim($string,$str);
echo $nStr.'</br>';
?>
Use str_replace http://php.net/manual/en/function.str-replace.php
$string="w;h;";
$str="h;";
Echo str_replace($str, "", $string);
Str_replace replaces $str with nothing. Leaving w;