adspace
How to check if a string contains a character or word in php?
Answer Posted / Niraj Kumar Srivastava
You can use the `strpos()` function in PHP. Here's an example of checking if a string contains a specific word:
```php
$haystack = 'Hello, World!';
$needle = 'World';
if (strpos($haystack, $needle) !== false) {
echo '$haystack contains $needle';
}
```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to create a web form?
What does $_files means?
how to detect a mobile device using php
Tell me what kind of things have you done on the social side?
sort term descripttion form, report and uery
What is the current stable version of php?
How can we extract string "pcds.co.in" from a string "https://info@pcds.co.in" using regular expression of php? More on reg can you explain
Which variable declarations within a class is invalid in php?
What is the current stable version of php? What advance thing in php7?
Name and explain five of the PHP error constants?
Explain me is it possible to destroy a cookie?
Write a program using while loop?
List some features of php that are deprecated in php7?
What is difference between static and final in php?
How to calculate the difference between two dates using php?