Creating an array of variables
suggest change$username = 'Hadibut';
$email = 'hadibut@example.org';
$variables = compact('username', 'email');
// $variables is now ['username' => 'Hadibut', 'email' => 'hadibut@example.org']
This method is often used in frameworks to pass an array of variables between two components.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents