O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

extract

Synopsis

int extract(array array[, int type[, string prefix]])

Sets the value of variables to the values of elements from an array. For each element in the array, the key is used to determine the variable name to set, and that variable is set to the value of the element.

The second argument, if given, takes one of the following values to determine behavior if the values in the array have the same name as variables already existing in the local scope:

EXTR_OVERWRITE (default)

Overwrite the existing variable

EXTR_SKIP

Don’t overwrite the existing variable (ignore the value provided in the array)

EXTR_PREFIX_SAME

Prefix the variable name with the string given as the third argument

EXTR_PREFIX_ALL

Prefix all variable names with the string given as the third argument

EXTR_PREFIX_INVALID

Prefix any invalid or numeric variable names with the string given as the third argument

EXTR_IF_EXISTS

Only replace variable if it exists in the current symbol table

EXTR_PREFIX_IF_EXISTS

Only create prefixed variable names if the nonprefixed version of the same variable exists

EXTR_REFS

Extract variables as references

The function returns the number of successfully set variables.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required