sx Posted April 7, 2007 Share Posted April 7, 2007 Ok I am wanting to check the content between the image tags in a post. I want to make sure the the links point to one of three hosts only. those hosts are tinypic, photobucket, imageshack. Here is what I got so far. $test = "[img=http://www.photobucket.com/files/rar.jpg]"; if (preg_match("/img([^\\[]*)\\/photobucket/",$test) || preg_match("/img([^\\[]*)\\/tinypic/",$test) || preg_match("/img([^\\[]*)\\/imageshack/",$test)){ echo "Hi";} else {echo "no";} But no matter what I put in there I get the "no". What am I doing wrong here? Link to comment https://forums.phpfreaks.com/topic/45976-preg_match-prob/ Share on other sites More sharing options...
neel_basu Posted April 7, 2007 Share Posted April 7, 2007 Try this <?php $test = "[img=http://www.photobucket.com/files/rar.jpg]"; if (preg_match("/^[\[img\]http:\/\/www\.][photobucket|tinypic|imageshack]/",$test)) { echo "Hi"; } else { echo "no"; } ?> Link to comment https://forums.phpfreaks.com/topic/45976-preg_match-prob/#findComment-223478 Share on other sites More sharing options...
sx Posted April 7, 2007 Author Share Posted April 7, 2007 That didn't work. Now I get the Hi no matter what I put in. Link to comment https://forums.phpfreaks.com/topic/45976-preg_match-prob/#findComment-223553 Share on other sites More sharing options...
neel_basu Posted April 7, 2007 Share Posted April 7, 2007 Try this <?php $test = "[img=http://www.photobucket.com/filesrar.jpg]"; if(ereg('^\[img\]http://www\.photobucket\.com|tinypic\.com|imageshack\.com',$test)) { echo "Hi"; } else { echo "no"; } ?> Link to comment https://forums.phpfreaks.com/topic/45976-preg_match-prob/#findComment-223556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.