How can the extract function be used in PHP to handle variables?

The `extract` function in PHP can be used to handle variables by extracting key-value pairs from an array into variables. This can be useful when working with associative arrays and you want to access the array values as individual variables. However, it is important to use `extract` with caution as it can lead to variable naming conflicts and security risks if not used carefully.

// Example of using extract function to handle variables
$data = array("name" => "John", "age" => 30, "city" => "New York");

extract($data);

echo $name; // Output: John
echo $age; // Output: 30
echo $city; // Output: New York