strchr(string $haystack, mixed $needle, bool $before_needle = false): string|false
Returns the substring starting from the match point onwards, or returns FALSE if no match is found in the string.
$text = "Hello world, the world is great!";
$result = strchr($text, "world");
echo $result;
world, the world is great!
$text = "Hello world, the world is great!";
$result = strchr($text, "world", true);
echo $result;
Output
Hello
$text = "Hello world, the world is great!";
$result = strchr($text, "World");
echo $result ? 'True':'False';
Output
False
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.