Explore tens of thousands of sets crafted by our community.
PHP Built-in Functions
35
Flashcards
0/35
strpos
Finds the position of the first occurrence of a substring in a string. Example: pos = 6
ksort
Sort an array by key. Example: ksort(
array_push
Pushes one or more elements onto the end of an array. Example: array_push(
preg_match
Performs a regular expression match. Example: string);
json_decode
Decodes a JSON string. Example: json, true); // associative array
usort
Sort an array by values using a user-defined comparison function. Example: usort(
array_merge
Merges one or more arrays into one array. Example: array1,
count
Counts all elements in an array, or properties in an object. Example: array);
implode
Joins array elements with a string. Example: array); // if string = 'one-two'
session_start
Start new or resume existing session. Example: session_start();
strtotime
Parses an English textual datetime into a Unix timestamp. Example:
file_get_contents
Reads entire file into a string. Example:
file_put_contents
Write a string to a file. Example: file_put_contents('filename.txt', 'Hello World');
date
Formats a local date and time. Example:
explode
Splits a string by a string. Example: array = ['one', 'two', 'three']
empty
Determine whether a variable is empty. Example: if (empty(
curl_exec
Perform a cURL session. Example: ch);
session_destroy
Destroys a session. Example: session_destroy();
header
Send a raw HTTP header. Example: header('Location: http://www.example.com/');
print_r
Prints human-readable information about a variable. Example: print_r(
curl_init
Initializes a new session and return a cURL handle. Example:
echo
Outputs one or more strings to the output buffer. Example: echo 'Hello, World!';
array_filter
Filters elements of an array using a callback function. Example: array, 'callbackFunction');
str_replace
Replaces all occurrences of the search string with the replacement string. Example: newString = 'Hello PHP'
array_map
Applies the callback to the elements of the given arrays. Example: n) { return n; },
sort
Sorts an array. Example: sort(
trim
Strips whitespace (or other characters) from the beginning and end of a string. Example: text);
json_encode
Encodes a value to JSON format. Example: array);
unset
Unsets a given variable. Example: unset(
array_reduce
Iteratively reduces the array to a single value using a callback function. Example: array, function(item) { return item; }, 0);
var_dump
Dumps information about a variable including its type and value. Example: var_dump(
strlen
Gets the length of a string. Example: length = 5
in_array
Checks if a value exists in an array. Example: array); //
isset
Determines if a variable is set and is not NULL. Example: if (isset(
curl_setopt
Set an option for a cURL transfer. Example: curl_setopt(
© Hypatia.Tech. 2024 All rights reserved.