What is the purpose of the extract function in PHP when loading variables from a file?

The purpose of the extract function in PHP when loading variables from a file is to extract all variables from an associative array and create variables in the current symbol table with the key names as the variable names and the values as the variable values. This can be useful when working with configuration files or when loading data from external sources.

// Load variables from a file using extract function
$config = include 'config.php';
extract($config);

// Now you can access the variables from the config file directly
echo $database_host;
echo $database_user;
echo $database_password;