PHP Functions Reference

50 functions • Fast search & favorites

All

Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one.

Parameters

mergecombinejoin

strlen

String

Returns the length of a string in bytes.

Parameters

lengthvalidationsecurity

substr

String

Returns a portion of a string specified by start and length parameters.

Parameters

substringextractslice

explode

String

Splits a string by a delimiter and returns an array of strings.

Parameters

splitparsecsv

Replaces all occurrences of search string with replacement string.

Parameters

replacesanitizeclean

is_array

Variable

Checks whether a variable is an array.

Parameters

validationtype-checksafety

trim

String

Returns a string with whitespace (or other characters) stripped from the beginning and end of string.

Parameters

cleanwhitespacesanitize

count

Array

Counts all elements in an array or properties in an object that implements Countable.

Parameters

countlengthsize

Checks if a value exists in an array.

Parameters

searchexistsvalidate

implode

String

Joins array elements with a string separator.

Parameters

joinconcatenatecombine

Reads entire file into a string. This is the preferred way to read the contents of a file into a string.

Parameters

filereadhttp

Returns the JSON representation of a value. Used for serializing PHP data structures to JSON format.

Parameters

jsonserializeapi

isset

Variable

Determines if a variable is declared and is different than null.

Parameters

checkvalidationsafety

unset

Variable

Destroys the specified variables. Unset removes the variable from memory.

Parameters

memorycleanupremove

empty

Variable

Determines whether a variable is empty. A variable is considered empty if it does not exist or if its value equals false.

Parameters

validationcheckinput

Performs a regular expression match against a string and returns whether a match was found.

Parameters

regexpatternvalidation

date

Date/Time

Formats a local date and time according to the specified format string.

Parameters

timeformattimestamp

Pushes one or more elements onto the end of an array and returns the new number of elements.

Parameters

arrayaddqueue

mysqli_query

Database

Performs a query against a MySQL database and returns a result set or boolean value.

Parameters

databasemysqlquery

Creates a password hash using a strong one-way hashing algorithm for secure password storage.

Parameters

securitypasswordhash

Converts special characters to HTML entities to prevent XSS attacks and ensure safe HTML output.

Parameters

securityxsssanitize

Converts all alphabetic characters in a string to lowercase.

Parameters

stringnormalizecase

Filters elements of an array using a callback function, returning only elements that pass the test.

Parameters

filtercallbackarray

uniqid

Misc

Generates a unique identifier based on the current time in microseconds.

Parameters

uniqueidentifiersession

round

Math

Rounds a float to the specified number of decimal places using specified rounding mode.

Parameters

mathprecisioncalculate

Applies a callback function to the elements of one or more arrays and returns a new array with the results.

Parameters

transformcallbackmap

Returns the values from a single column in a multi-dimensional array or array of objects.

Parameters

extractcolumndatabase

pathinfo

File System

Returns information about a file path including directory, basename, extension, and filename.

Parameters

filepathextension

strpos

String

Finds the position of the first occurrence of a substring within a string.

Parameters

searchpositionfind

filter_var

Validation

Filters a variable with a specified filter, used for validating and sanitizing data.

Parameters

validatesanitizesecurity

Calculates and returns the sum of all values in an array as an integer or float.

Parameters

calculatetotalmath

Formats a number with grouped thousands and customizable decimal/thousand separators.

Parameters

formatdisplaycurrency

Returns all keys or a subset of keys from an array, optionally filtered by value.

Parameters

keysextractstructure

Returns all values from an array with numeric keys, effectively reindexing the array.

Parameters

valuesreindexclean

Decodes a JSON string into a PHP variable (object or array).

Parameters

jsondecodeapi

Extracts a slice of an array based on offset and length parameters without modifying the original array.

Parameters

sliceextractpagination

time

Date/Time

Returns the current Unix timestamp (number of seconds since January 1, 1970 00:00:00 GMT).

Parameters

timestamptimeunix

Removes duplicate values from an array and returns the array with unique values only.

Parameters

uniquededuplicatefilter

usort

Array

Sorts an array by values using a user-defined comparison function, losing original keys.

Parameters

sortcustomcompare

microtime

Date/Time

Returns the current Unix timestamp with microseconds for high-precision timing measurements.

Parameters

microtimeprecisionbenchmark

Compares two or more arrays and returns the values from the first array that are not present in any of the other arrays.

Parameters

comparedifferencefilter

Writes data to a file. This is the preferred way to write data to a file as it handles opening, writing, and closing automatically.

Parameters

writefilesave

strtr

String

Translates characters or replaces substrings in a string using either character mapping or replacement pairs.

Parameters

replacetranslatesubstitute

Parses a URL and returns its components as an associative array or a specific component as a string.

Parameters

parseurlcomponents

Splits an array into chunks of specified size, returning a multidimensional indexed array with each chunk containing the specified number of elements.

Parameters

splitchunkbatch

Searches an array for a specific value and returns the corresponding key if found, or false if not found.

Parameters

searchfindkey

Performs a regular expression search and replace operation on a string or array of strings.

Parameters

regexpatternreplace

rand

Math

Generates a pseudo-random integer within a specified range or between 0 and getrandmax().

Parameters

randomgeneratenumber

max

Math

Returns the highest value among the given values, or the highest value in an array.

Parameters

maximumcomparehighest

min

Math

Returns the lowest value among the given values, or the lowest value in an array.

Parameters

minimumcomparelowest