× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
5
a
5
k
5
c
5
B
5
l
5
C
4
s
4
a
4
t
4
i
4
r
4
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 340 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
  1326 People Browsing
Related Images
  
 339
  
 535
  
 293
Your Opinion
Who's your favorite biologist?
Votes: 586