Is it possible to skip a strpos/strrpos position?
$string = "This is a cookie 'cookie'.";
$finder = "cookie";
$replacement = "monster";
if (strrpos($string, $finder) !== false)
str_replace($finder, $replacement, $string);
I want to skip the 'cookie' and replace the plain cookie so it'll result in "This is a monster 'cookie'."
I don't have qualms with it finding 'cookie' first and then checking it (Obviously necessary to determine it shouldn't be replaced), but I want to make sure that while 'cookie' is still there, I can use the same function to find the unquoted cookie.
Alternatively, is there a function I haven't found yet (Through hours of searching) to get all indices of a particular word so I can check them all through a loop without the use of regex?
It's important that it's the index, not the word itself, as there are other checks that have to be done based on where in the string the word's located.