I have a PHP variable that contains a bunch of data, and I was wondering if there's a way to convert the individual variables within it into an array. I know about the "extract" function in PHP which can convert an array into variables, but I want to do the opposite.
For example, let's say I have these variables:
$name = "John";
$age = 30;
$city = "New York";
And I want to convert them into an array like this:
$person = array("name" => "John", "age" => 30, "city" => "New York");
I've tried searching for a solution, but all I can find is information on how to use the "extract" function. Is there a built-in PHP function or any other method that can achieve this kind of conversion?
Any help would be greatly appreciated! Thank you in advance.