Change a string based on a pattern

bossua

New Member
I want to change a string in PHP by deleting the first and the last char but ONLY IF they are equal.Let me give some examples:\[code\]' abc ' should become 'abc''abc a' should become 'bc '' abc a' should not change\[/code\]How do I do it? Thanks for the help, the regex based solution works.
 
Back
Top