yfjpe Posted November 15, 2006 Share Posted November 15, 2006 Hi there, I am new to PHP and have what is probably a very basic question.In Perl, when you want to find a certain string within a value, you can use the following:if ($value =~ /$string/) { }So, if $value is "Toob Goob Joob" and you want to find "Goob", the if statement above would be true.All I need to know is how to do this in PHP. Thanks in advance for your help. Link to comment https://forums.phpfreaks.com/topic/27385-php-equivalent-of-perls-~/ Share on other sites More sharing options...
obsidian Posted November 15, 2006 Share Posted November 15, 2006 That type of matching (=~) is using regular expressions to run the match. This is the equivalent of using preg_match() in PHP. Here is a similar equivalent:[code]<?php$string = "Toob Goob Joob";if (preg_match('/Goob/', $string)) { // match found}?>[/code] Link to comment https://forums.phpfreaks.com/topic/27385-php-equivalent-of-perls-~/#findComment-125248 Share on other sites More sharing options...
yfjpe Posted November 15, 2006 Author Share Posted November 15, 2006 Thank you very very much! Link to comment https://forums.phpfreaks.com/topic/27385-php-equivalent-of-perls-~/#findComment-125253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.