TRIM在PHP中的不同行为

I have a piece of code, from this i want to remove some words from string but the trim() function is not showing proper output.

The code is below

<?php
$mystring = '/word-quotes-hope';
$findme   = '/word-quotes-';
echo $str = trim($mystring, $findme);
?>

and its output is hop, but it should be hope

Its working example http://codepad.viper-7.com/FxLZkp

Anybody knows why this is happening.

Because trim uses the second string individual characters, not the whole string, and in your case it has an e in it, and the string ends with e so off it goes.

Try to use it with "ltrim"

echo $str = ltrim($mystring, $findme);

it will trims your string on "left"