× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
5
o
5
4
m
4
b
4
x
4
a
4
l
4
t
4
S
4
m
3
s
3
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 305 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
  1137 People Browsing
Related Images
  
 278
  
 1301
  
 1068
Your Opinion
Which of the following is the best resource to supplement your studies:
Votes: 249