PHP

PHP Menu

PHP

stristr() Function - Definition, Syntax, Parameters, Examples

Definition

The stristr() function searches for the first occurrence of a string inside another string.

Syntax

stristr(string, search, before_search)

Parameters

Parameter Description
string Required. Specifies the string to search.
search Required. Specifies the string to search for. If this parameter is a number, it will search for the character matching the ASCII value of the number.
before_search Optional. A boolean value whose default is false. If set to true, it returns the part of the string before the first occurrence of the search parameter.

Example

<?php
echo stristr("Welcome to PHP!", "PHP"); echo stristr("Welcome to PHP!", "PHP", true);

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods