I have a string that begins with an empty space and a +
sign :
$s = ' +This is a string[...]';
I can't figure out how to remove the first +
sign using PHP. I've tried ltrim
, preg_replace
with several patterns and with trying to escape the +
sign, I've also tried substr
and str_replace
. None of them is removing the plus sign at the beginning of the string. Either it doesn't replace it or it remplace/remove the totality of the string. Any help will be highly appreciated!
Edit : After further investigation, it seems that it's not really a plus sign, it looks 100% like a +
sign but I think it's not. Any ideas for how to decode/convert it?
Edit 2 : There's one white space before the +
sign. I'm using get_the_excerpt
Wordpress function to get the string.
Edit 3 : After successfully removing the empty space and the +
with substr($s, 2);
, Here's what I get now :
$s == '#43;This is a string[...]'
Wiki : I had to remove 6 characters, I've tried substr($s, 6);
and it's working well now. Thanks for your help guys.