PHP stripos() Function: Case‑Insensitive Search for Substring Position
This article explains how PHP's stripos() function performs a case‑insensitive search to locate the first occurrence of a substring within a string, detailing its parameters, return values, and providing a complete example with expected output.
The stripos() function in PHP finds the position of the first occurrence of a substring within a string without regard to case.
Parameters:
$haystack – the string to search in.
$needle – the substring to look for; if not a string it is converted to an integer.
$offset (optional) – the position in $haystack to start searching from; the returned index is still relative to the start of the string.
Return value: The numeric position of $needle in $haystack (starting at 0) or FALSE if the needle is not found.
Example:
The script outputs a message indicating that the character ‘a’ was not found in “xyz”, and that it was found at position 0 in “ABC”.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.