Using compact() with the elements of an array?
Is it possible to apply compact() to the elements of an array? For instance, instead of
$name = 'John';
$city = 'Denver';
$state = 'Colorado';
print_r(compact('name', 'city', 'state'));
I was thinking of iterating over $arr with a foreach() loop and compact()ing each element individually, but I don't know how to pass the element keys as varnames that make sense to compact().
$arr['name'] = 'John';
$arr['city'] = 'Denver';
$arr['state'] = 'Colorado';
print_r(compact(...on each key of $arr...));