Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 526
  • Last Modified:

PHP - Is $string1 contained in $string2 ?

Hello,

I want to see if this exact string   href='r/  is contained in $mtopics
If not, then run 2 lines of code.

But, it always runs it, even if the string is present.
Can you help?

<?PHP
if(stristr($mtopics, "href='r/") === FALSE) {
$mtopics=str_replace("href='","href='$pre",$mtopics);
$reltopics=str_replace("href='","href='$pre",$reltopics);
}
?>

Thanks, Greg
0
gregsschipper
Asked:
gregsschipper
1 Solution
 
petr_hlucinCommented:
Use the following:
<?PHP
if(stristr($mtopics, 'href=\'r/') === FALSE) {
$mtopics=str_replace("href='","href='$pre",$mtopics);
$reltopics=str_replace("href='","href='$pre",$reltopics);
}
?>

Open in new window

0
 
Ray PaseurCommented:
Please post the test data, thanks.
0
 
gregsschipperAuthor Commented:
The BEST! Many Thanks, Greg - www.adventdigital.net
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now