PHP Arrays Creating an array of variables


Example

$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.