I have a string in php example below.
$string = "This is my website example.org check it out!";
if( preg_match( '/\w+\.(?:com|org)/i', $string, $matches)) {
var_dump( $matches[0]);
echo '' . $matches[0] . '';
}
It will echo out
string(11) "example.org" example.org
I need it to only echo out only
example.org
You will need a regular expression to do this. Here is a start:
The regex is:
This will output:
You will need to adapt it to include subdomains and protocols, if necessary.