Jump to content

Archived

This topic is now archived and is closed to further replies.

gerkintrigg

[resolved] Contains

Recommended Posts

Hi!
I wondered what the best function, command line (or whatever else you want to call it) I should use to determine if a string contains another string.

so for example I need to know what the "contains" below needs to be changed to:

[code]<?php
if ($string_1 contains $string_2){
//do something;
}
?>[/code]

Thanks for your help.

Share this post


Link to post
Share on other sites
[code=php:0]
$a = "thisisfoo";
$b = "foo";
if (strstr($a,$b)) {
  echo $b." found in ".$a;
}
[/code]

Share this post


Link to post
Share on other sites
Nice and easy..
Thanks very much.
I wan't sure what to search for on php.net, but I'll not be forgetting that!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.