I need to chnage some words inside strings - I must separate string on 2 or more words - or to add space before and after word. For example I have shopifystore - this must be separated into 2 words": shopify and store, so result must be: "shopify store". One more example - I have dogsstore - this must be separated into 2 words": dogs and store, so result must be: "dogs store"
So, I write some function, but results are not so good. My function:
function englishchange($string) {
$latin = array('dogs','dog','stores','store','shops','shop','shopify');
$latinchanged = array(' dogs ',' dog ',' stores ',' store ',' shops ',' shop ',' shopify ');
return str_replace($latin, $latinchanged, $string);
}
$englishchanged = (englishchange('shopifystore'));
But the resilt from "dogsstore" is: "dog s store" and "shopifystore" going to: "shop ify store". Can anyone help me, please, to rewrite php code to get the right result?