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 Link to comment https://forums.phpfreaks.com/topic/117754-solved-search-a-word-in-a-string/ 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'; } ?> Link to comment https://forums.phpfreaks.com/topic/117754-solved-search-a-word-in-a-string/#findComment-605664 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 Link to comment https://forums.phpfreaks.com/topic/117754-solved-search-a-word-in-a-string/#findComment-605671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.