ravi181229 Posted August 1, 2008 Share Posted August 1, 2008 Hi there, I want to search a word in a string. In my application, user will post embed link. I will fetch 'site names' from database and search database value (site names) in the user posted values(embed link). for example: $word = "abcd.com"; $string = "<embed src="abcd.com" width="550" height="400"></embed>"; I want to search $word in $string. Need help. Thanks & Regards, Ravi Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 1, 2008 Share Posted August 1, 2008 So you're just tring to find out if $word is in $string? Use strpos: <?php $word = "abcd.com"; $string = '<embed src="abcd.com" width="550" height="400"></embed>'; if(strpos($string,$word) !== FALSE){ echo $word.' occurs in the string'; }else{ echo $word.' does not occur in the string'; } ?> Quote Link to comment Share on other sites More sharing options...
ravi181229 Posted August 1, 2008 Author Share Posted August 1, 2008 Hi GingerRobot, Thanks a lot. It worked. Thanks & Regards, Ravi Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.