PHP Built-in Functions by Category
PHP ships with thousands of built-in functions grouped into extensions. This list covers the functions developers look up most often, organised by category. Every page explains the syntax, parameters and return value, shows several examples with their real output, lists common mistakes, and includes an editor so you can run the code in your browser.
String Functions
Measure, search, cut, replace, split, join and format strings.
- strlen() - Get string length in bytes
- substr() - Return part of a string
- strpos() - Find the position of a substring
- str_contains() - Check if a string contains a substring (PHP 8+)
- str_replace() - Replace all occurrences of a string
- explode() - Split a string into an array
- implode() - Join array elements into a string
- trim() - Strip whitespace or characters from both ends
- sprintf() - Return a formatted string
Array Functions
Transform, filter, reduce, merge, search and de-duplicate arrays.
- array_map() - Apply a callback to every element
- array_filter() - Keep elements that pass a test
- array_reduce() - Reduce an array to a single value
- array_merge() - Merge one or more arrays
- in_array() - Check if a value exists in an array
- array_search() - Find the key of a value
- array_unique() - Remove duplicate values
JSON Functions
Encode PHP values to JSON and decode JSON strings.
- json_encode() - Convert a PHP value to JSON
- json_decode() - Decode JSON into an array or object
Regular Expression Functions
Pattern matching and replacement with Perl-compatible regular expressions (PCRE).
- preg_match() - Match a regular expression
- preg_replace() - Search and replace with a regular expression
Output and Debugging
Inspect variables while you develop.
- print_r() - Print arrays and objects in readable form
How to Use This Reference
Each function reference page includes:
- Function Signature: Complete syntax showing parameters and types
- Description: What the function does and when to use it
- Parameters: Detailed explanation of each parameter
- Return Values: What the function returns and possible return types
- Examples: Practical code examples demonstrating usage
- Notes & Gotchas: Common pitfalls, edge cases, and best practices
Test Functions Online
All function examples can be tested using our online PHP compiler. Click any function to view its documentation and run example code directly in your browser. Modify the examples to experiment with different parameters and see how the function behaves with different inputs.