Is there a way to delete everything before and including the last instance of a specific character?
I have some lines that contain > , for example.
>
the > cat > sat > on > the > mat
welcome > home
I need formatting strings so they become
mat
home
You can use regex ...
$str = preg_replace('/^.*>\s*/', '', $str);
CodePad
... or use explode() ...
explode()
$tokens = explode('>', $str); $str = trim(end($tokens));
... or substr() ...
substr()
$str = trim(substr($str, strrpos($str, '>') + 1));
There are probably many other ways to do this. Keep in mind that my examples crop the resulting string. You can always edit my sample code if this is not a requirement.