What is "extract" in PHP?

9

I was analyzing a PHP code, and a script was used extract .

I searched in some PHP documents and the examples are a bit abstract and unfortunately I did not realize much.

I would like in a general case to know what extract does in PHP? (If possible a concrete example).

    
asked by anonymous 29.12.2016 / 00:59

1 answer

11

Get an associative array and declare variables, named after the keys, and the contents of the variable, the key value of the array.

Here's an example:

$teste = ["variavel" => "valor da variável"];

extract($teste);

echo $variavel;   //vai imprimir "valor da variavel"

link

Here are some more intuitive examples.

    
29.12.2016 / 01:03