I want to remove some text from my title (using wordpress). Example: Alexandra Stan - Mr. Saxobeat Output: Mr. Saxobeat
I tried many codes, one of this work perfect:
$str = "this comes before – this comes after";
$char = " - ";
$strpos = strpos($str, $char);
$str = substr($str, $strpos+strlen($char));
echo $str;
but after many times of trying and get upsed... i see that in my wordpress article page, when i type "-" in title, wordpress change it automatically with: "–" who is different (bigger) than normal one "-" (copy in another font and you will see the difference).
I try replace "-" with "–" but output is " s comes before - this comes after "
Thanks!
That's an em dash you're trying to replace. However, you're looking for a regular dash. Try running the string through this mess of code first and reading the blog article I got it from
EDIT
A complete working example, basically pasting the example code from the blog article and fixing a small mistake with your
substr