compact()
compact() is a native PHP function, which creates an array containing variables and their values, from a list of variable names.
It is the opposite of extract().
<?php
$a = '1';
$b = '2';
$array = compact('a', 'b');
// ['a' => 1, 'b' => 2];
?>