This question already has an answer here:
I need to remove the domain name from the end of a string. I have tried the following code:
$domainNAME="example.com";
$result="_xmpp-client._tcp.example.com..example.com"
$string = $result;
$string = str_replace(".".$domainNAME, " ", $string);
Here the result is "_xmpp-client._tcp.". But the result should be "_xmpp-client._tcp.example.com.".
I need to remove the domain name only from the end of string, if domain name exists anywhere in the string it should not be removed.How can I change the code for that?
Any help should be appreciated!
</div>