Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

PHP Built-in Functions

35

Flashcards

0/35

Still learning
StarStarStarStar

strpos

StarStarStarStar

Finds the position of the first occurrence of a substring in a string. Example: pos=strpos(HelloWorld,World);//pos = strpos('Hello World', 'World'); // pos = 6

StarStarStarStar

ksort

StarStarStarStar

Sort an array by key. Example: ksort(array);array);

StarStarStarStar

array_push

StarStarStarStar

Pushes one or more elements onto the end of an array. Example: array_push(array,value);array, 'value');

StarStarStarStar

preg_match

StarStarStarStar

Performs a regular expression match. Example: matches=pregmatch(/pattern/,matches = preg_match('/pattern/', string);

StarStarStarStar

json_decode

StarStarStarStar

Decodes a JSON string. Example: array=jsondecode(array = json_decode(json, true); // associative array

StarStarStarStar

usort

StarStarStarStar

Sort an array by values using a user-defined comparison function. Example: usort(array,comparisonFunction);array, 'comparisonFunction');

StarStarStarStar

array_merge

StarStarStarStar

Merges one or more arrays into one array. Example: mergedArray=arraymerge(mergedArray = array_merge(array1, array2);array2);

StarStarStarStar

count

StarStarStarStar

Counts all elements in an array, or properties in an object. Example: numItems=count(numItems = count(array);

StarStarStarStar

implode

StarStarStarStar

Joins array elements with a string. Example: string=implode(,string = implode('-', array); // if array=[one,two],array = ['one', 'two'], string = 'one-two'

StarStarStarStar

session_start

StarStarStarStar

Start new or resume existing session. Example: session_start();

StarStarStarStar

strtotime

StarStarStarStar

Parses an English textual datetime into a Unix timestamp. Example: time=strtotime(nextweek);time = strtotime('next week');

StarStarStarStar

file_get_contents

StarStarStarStar

Reads entire file into a string. Example: contents=filegetcontents(filename.txt);contents = file_get_contents('filename.txt');

StarStarStarStar

file_put_contents

StarStarStarStar

Write a string to a file. Example: file_put_contents('filename.txt', 'Hello World');

StarStarStarStar

date

StarStarStarStar

Formats a local date and time. Example: date=date(Ymd);date = date('Y-m-d');

StarStarStarStar

explode

StarStarStarStar

Splits a string by a string. Example: array=explode(,,one,two,three);//array = explode(',', 'one,two,three'); // array = ['one', 'two', 'three']

StarStarStarStar

empty

StarStarStarStar

Determine whether a variable is empty. Example: if (empty(var))/.../var)) { /* ... */ }

StarStarStarStar

curl_exec

StarStarStarStar

Perform a cURL session. Example: output=curlexec(output = curl_exec(ch);

StarStarStarStar

session_destroy

StarStarStarStar

Destroys a session. Example: session_destroy();

StarStarStarStar

header

StarStarStarStar

Send a raw HTTP header. Example: header('Location: http://www.example.com/');

StarStarStarStar

print_r

StarStarStarStar

Prints human-readable information about a variable. Example: print_r(array);array);

StarStarStarStar

curl_init

StarStarStarStar

Initializes a new session and return a cURL handle. Example: ch=curlinit(http://www.example.com/);ch = curl_init('http://www.example.com/');

StarStarStarStar

echo

StarStarStarStar

Outputs one or more strings to the output buffer. Example: echo 'Hello, World!';

StarStarStarStar

array_filter

StarStarStarStar

Filters elements of an array using a callback function. Example: filtered=arrayfilter(filtered = array_filter(array, 'callbackFunction');

StarStarStarStar

str_replace

StarStarStarStar

Replaces all occurrences of the search string with the replacement string. Example: newString=strreplace(World,PHP,HelloWorld);//newString = str_replace('World', 'PHP', 'Hello World'); // newString = 'Hello PHP'

StarStarStarStar

array_map

StarStarStarStar

Applies the callback to the elements of the given arrays. Example: squared=arraymap(function(squared = array_map(function(n) { return nn * n; }, array);array);

StarStarStarStar

sort

StarStarStarStar

Sorts an array. Example: sort(array);array);

StarStarStarStar

trim

StarStarStarStar

Strips whitespace (or other characters) from the beginning and end of a string. Example: text=trim(text = trim(text);

StarStarStarStar

json_encode

StarStarStarStar

Encodes a value to JSON format. Example: json=jsonencode(json = json_encode(array);

StarStarStarStar

unset

StarStarStarStar

Unsets a given variable. Example: unset(var);var);

StarStarStarStar

array_reduce

StarStarStarStar

Iteratively reduces the array to a single value using a callback function. Example: sum=arrayreduce(sum = array_reduce(array, function(carry,carry, item) { return carry+carry + item; }, 0);

StarStarStarStar

var_dump

StarStarStarStar

Dumps information about a variable including its type and value. Example: var_dump(variable);variable);

StarStarStarStar

strlen

StarStarStarStar

Gets the length of a string. Example: length=strlen(Hello);//length = strlen('Hello'); // length = 5

StarStarStarStar

in_array

StarStarStarStar

Checks if a value exists in an array. Example: exists=inarray(apple,exists = in_array('apple', array); // exists=trueorfalseexists = true or false

StarStarStarStar

isset

StarStarStarStar

Determines if a variable is set and is not NULL. Example: if (isset(var))/.../var)) { /* ... */ }

StarStarStarStar

curl_setopt

StarStarStarStar

Set an option for a cURL transfer. Example: curl_setopt(ch,CURLOPTRETURNTRANSFER,true);ch, CURLOPT_RETURNTRANSFER, true);

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.