× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
New Topic  
5seal 5seal
wrote...
Posts: 147
5 years ago
Let's say:

Code:
$a = 'I am happy?';

if ($a contains 'happy')
    echo 'true';

How is this done?
Read 341 times
3 Replies

Related Topics

Replies
wrote...
Staff Member
5 years ago
Try this:

Code:
$a = 'I am happy?';

if (strpos($a, 'happy') !== false) {
    echo 'true';
}
Ask another question, I may be able to help!
5seal Author
wrote...
5 years ago
That works perfectly!

What if we want "am" and "happy"? How do I adjust the code above? Thinking Face
wrote...
Staff Member
5 years ago
Code:
if (strpos($a, 'happy') !== false || strpos($a, 'am') !== false) {
    echo 'true';
}
Ask another question, I may be able to help!
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1290 People Browsing
Related Images
  
 232
  
 535
  
 304
Your Opinion
Where do you get your textbooks?
Votes: 372