Hi, how can I match this fill sentence please?
Forum-Exchange-link-Add-your-link-Back-links
with PHP?
I have tried this but get error:
$actual_link = "$_SERVER[REQUEST_URI]";
$string = str_replace('-', ' ', $actual_link);
$string = str_replace('/', ' ', $string);
echo $string;
if (preg_match("Forum Exchange link Add your link Back links", $string, $matches))
{
echo "negative";
}
else
{
echo "positive";
}
preg_match(): Delimiter must not be alphanumeric or backslash
You need a delimiter character around your pattern, so that PCRE knows where the pattern begins and ends.
if (preg_match("Forum Exchange link Add your link Back links", $string, $matches))
=>
if (preg_match("~Forum Exchange link Add your link Back links~", $string, $matches))
rpkamp
3
If you have a fixed string there really is no need for a regular expression. Just use strpos instead.
if (strpos($input, 'Forum Exchange link Add your link Back links') !== false) {
echo 'negative';
} else {
echo 'positive';
}
Of for some reason you really want to use regular expressions (again, I don’t see why), do as @StarLion said
Thanks guys very much works great. Used your codes to create one master one