CopyPastor

Detecting plagiarism made easy.

Score: -1; Reported for: Open both answers

Possible Plagiarism

Plagiarized on 2018-02-14
by Rawand Ahmed Shaswar

Original Post

Original - Posted on 2010-12-06
by codaddict



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can use the `strpos()` function which is used to find the occurrence of one string inside another one: $a = 'my_name_is'; if (strpos($a, '_') !== false) { echo 'true'; } Note that the use of `!== false` is deliberate; `strpos()` returns either the offset at which the needle string begins in the haystack string, or the boolean false if the needle isn't found. Since 0 is a valid offset and 0 is "falsey", we can't use simpler constructs like `!strpos($a, '_')`.
You can use the [`strpos()`][1] function which is used to find the occurrence of one string inside another string:
$a = 'How are you?';
if (strpos($a, 'are') !== false) { echo 'true'; }
Note that the use of `!== false` is deliberate; `strpos()` returns either the offset at which the needle string begins in the haystack string, or the boolean `false` if the needle isn't found. Since 0 is a valid offset and 0 is "falsey", we can't use simpler constructs like `!strpos($a, 'are')`.

[1]: http://php.net/manual/en/function.strpos.php

        
Present in both answers; Present only in the new answer; Present only in the old answer;