什么是相当于Perl的正则表达式替换的PHP?

I'm converting one of my old Perl programs to PHP, but having trouble with PHP's string handling in comparison to Perl.

In Perl, if I wanted to find out if $string contained this, that or the_other I could use:

if ($string =~ /this|that|the_other/){do something here}

Is there an equivalent in PHP?

You can use PHP's preg_match function for a simple regex test.

if ( preg_match( "/this|that|the_other/", $string ) ) { 
    ...
}

In PHP you can use preg_match function as:

if( preg_match('/this|that|the_other/',$string) ) {
  // do something here.
}

You can either use a regular expression (e.g. preg_match):

if(preg_match('/this|that|the_other/', $string))

or make it explicit (e.g. strstr):

if(strstr($string, 'this') || strstr($string, 'that') || strstr($string, 'the_other'))