PHP extract() Function

The extract( ) function is an inbuilt function of PHP, and it is used to import variables into the local symbol table from an array. This function was introduced in 4.0.

Syntax

Parameters

array: This parameter is required. This specifies the array to use.

flags: This parameter is optional. The extract() function checks for invalid variable names and collisions with existing variable names. This parameter specifies how invalid and colliding names will be treated.

prefix: This parameter is optional. This parameter specifies the prefix. The prefix is automatically separated from the array key by an underscore character. Also this parameter is required only when the parameter $extract_rule is set to EXTR_PREFIX_SAME, EXTR_PREFIX_ALL, EXTR_PREFIX_INVALID or EXTR_PREFIX_IF_EXISTS.

Returns

The extract( ) function returns the number of variables extracted on success.

Example 1

Output:

ajeetnoida

Example 2

Output:

batmanjoker

Example 3

Output:

tendulkarvirat

Example 4

Output:

ASSAMKERELA