Hey everyone!
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.

Hey there!
Yes, you can definitely convert your individual variables into an array in PHP. One way to achieve this is by manually creating an array and assigning each variable to a specific key.
In your case, you can use the following code to convert the variables into an array:
By assigning each variable to the corresponding key in the array, you can easily access the values using the array indexes. In this example, `$person["name"]` will give you the value "John", `$person["age"]` will give you 30, and `$person["city"]` will give you "New York".
I've used this method many times in my projects, and it works perfectly for converting individual variables into an array. Give it a try and let me know if you have any further questions!
Hope this helps!