Skip to content
PHP

string functions API Reference

PHP's built-in string functions for measuring, searching, slicing, replacing and transforming strings.

By EZ4Code Team

string functions

Procedural string functions provided by the PHP standard library.

strlen(string $string): int

Returns the length of the given string in bytes (not characters).

Returns: int

strpos(string $haystack, string $needle, int $offset = 0): int|false

Finds the numeric position of the first occurrence of needle in haystack. Returns false if not found.

Returns: int|false

substr(string $string, int $offset, ?int $length = null): string

Returns the portion of string specified by offset and length.

Returns: string

str_replace(array|string $search, array|string $replace, string|array $subject): string|array

Replaces all occurrences of search with replace in subject.

Returns: string|array

strtolower(string $string): string

Returns string with all ASCII alphabetic characters converted to lowercase.

Returns: string

explode(string $separator, string $string, int $limit = PHP_INT_MAX): array

Splits a string by a separator and returns an array of the pieces.

Returns: array

trim(string $string, string $characters = " \n\r\t\v\x00"): string

Strips whitespace (or other characters) from the beginning and end of a string.

Returns: string

More PHP API References