I want to find and display data found between two characters in a string.
Example>
Form sends the following to the .php page....
$data1 = "The Domain Name [somedomain.com] has been renewed";
I want to be able to pull out and display only "somedomain.com".
Example, I want a variable called $domain to only hold the domain name itself, without the brackets or the text.
somedomain.com
I have investigated function strstr().
$data1 = "The Domain [somedomain.com] has been renewed";
$domain = strstr($data1, '[');
OUTPUTS:
[somedomain.com] has been renewed
I can then use substr() to remove the first "[".
$domain = substr("$domain", 1);
OUTPUTS
somedomain.com] has been renewed
But, I am stuck, conceptually, with what to do to trim the end after .com . Note, somedomain.com will change. One run, it could be somedomain.com and the next, it could be "somethingelseentirely.com". Thus, the character length of that part of the string will change each time.
Can someone direct me. At first glance, this seems like it should be so simple, but I cannot seem to conceptualize the solution.
Thanks for any help you can provide.