swamp Posted July 6, 2009 Share Posted July 6, 2009 Hi there, I need to check if there has been a url submitted from a form so if a post was "hi there, check out this website http://www.somewebsite.com/ - what do you think?" when it was sent to the script it would do something like if $_POST['comment'] has url in it then do function urlExists($url) Link to comment https://forums.phpfreaks.com/topic/164946-if-text-contains-url/ Share on other sites More sharing options...
nloding Posted July 6, 2009 Share Posted July 6, 2009 Look into regular expressions -- http://www.regular-expressions.info/php.html Link to comment https://forums.phpfreaks.com/topic/164946-if-text-contains-url/#findComment-869780 Share on other sites More sharing options...
MadTechie Posted July 6, 2009 Share Posted July 6, 2009 <?php if (preg_match('/\b(https?:\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$])/i', $_POST['comment'], $regs)) { echo "url {$regs[1]} found"; } ?> Link to comment https://forums.phpfreaks.com/topic/164946-if-text-contains-url/#findComment-869782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.