How to trim multiple characters at begin and end of string.
string should be something like {Hello {W}orld}
.
i want to trim both {
and }<
Is there always a character at the beginning and at the end, that you want to remove? If so you could just use the following:
<?php
$string = '{Hello {W}orld}';
echo substr( $string, 1, strlen( $string )-2 );
?>
See: http://codepad.org/IDbG6Km2
$str = "{Hello {W}orld}";
$str = trim($str, "{}");
echo "Trimmed: $str";