I realized that I have some weird issue with str_replace() where it seemingly doesn’t replace every occurence of $search with $replace even tho i have not specified a $count variable…
My code
echo "head_title_array ".html_entity_decode($head_title_array['title'])."\n\n";
$Mytitle = strtolower(str_replace(" ", "_", html_entity_decode($head_title_array['title'])));
echo "Mytitle ".$Mytitle;
and the output:
head_title_array Stay & play golf packages
Mytitle stay_& play_golf_packages
Why is that? I would expect $Mytitle to have a value of “stay_&_play_golf_packages“.
What’s going on here?
Any help is appreciated!!!
Probably you have unicode spaces in your string.
Possible solution for you is to use
preg_replaceUnicode character properties