Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

preg_match question

Status
Not open for further replies.
Feb 16, 2003
87
GB
Hello,

I'm using the code below to check the URL of the current page to see if the word 'apple' appears. I would like to adapt it to check whether 'apple' OR 'banana' appears - what would I need to change?

<?php
$thispage = $_SERVER['REQUEST_URI'];

if (preg_match ("/apple/i", $thispage)) {
print "";
} else {
echo "not an apple of banana";
}
?>
 
I believe this is what you're looking for

Code:
<?php
  $thispage = $_SERVER['REQUEST_URI'];
  
  if (preg_match ("/(apple)|(banana)/i", $thispage)) {
      print "";
  } else {
      echo "not an apple of banana";
  }
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top