String Functions

PHP has several built-in functions for text processing and the manipulation of strings.

A list of PHP string and text processing functions can be found in the table below:

String Functions

explode()
Splits a given string by a delimiter and returns an array of the substrings produced.
sprintf()
Returns a string with a specified formatting.
str_replace()
Returns a string with occurrences of a specified substring replaced by another string.
strlen()
Returns the number of bytes in a given string.
substr()
Returns a portion of a specified string.

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn PHP on Codecademy