Jump to content

Trying to match a url


ballhogjoni

Recommended Posts

Better off with filter_var than regex:

 

 


$uris = array(
   'www.google.com',
   'http://www.google.com',
   'google.com',
   'rfdgedg'
);
foreach($uris as $uri)
   var_dump(filter_var($uri, FILTER_VALIDATE_URL));

boolean false
string 'http://www.google.com' (length=21) 
boolean false 
boolean false

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.