please help a noob still learning. I have searched for a solution but most of what I found uses regex and I’m hoping to accomplish this without using regex.
I have the following repeated like 10 times for multiple fruits at the top of my page and all is working fine:
?>
<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/apple/",$referrer)) {
header("Refresh:0;url=http://mysite.com/fruit/");
exit;
}
?>
?>
<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/orange/",$referrer)) {
header("Refresh:0;url=http://mysite.com/fruit/");
exit;
}
?>
But I’m trying to condense it down to something like this where I can simply just add a new ‘fruit’ when / if needed.
if (preg_match("/apple/", $referrer) || preg_match("/orange/", $referrer) || preg_match("/peach/", $referrer) || preg_match( "and on!! --)) { ...
Yes I’m aware of the wide scope of the preg_match I have.
You may try “or” condition
Please note that it will match “crabapple” as well as there is not restrictions on the word boundaries.