Backend Development 3 min read

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.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP stripos() Function: Case‑Insensitive Search for Substring Position

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”.

BackendPHPstring-functionscase-insensitivestriposphp tutorial
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.