How to check if a string contains a character or word in php?



How to check if a string contains a character or word in php?..

Answer / 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

More PHP Interview Questions

Is there an easy way to delete an element from a php array?

1 Answers  


Write a program to get lcm of two numbers using php?

1 Answers  


What is difference between web service and api?

1 Answers  


What does csrf token mean?

1 Answers  


Draw the architecture of Zend engine?

4 Answers  


Does php support polymorphism?

1 Answers  


What is meant by pdo in php?

1 Answers  


Is php dead 2019?

1 Answers  


Why would we use === instead of ==?

1 Answers  


How do you pass a variable by value in php?

1 Answers  


Is laravel easy to learn?

1 Answers  


How to call php function in jquery?

1 Answers  


Categories