Reputation: 91213
I have the following variables:
$something = 'whatever';
$hello = array();
$test = 123;
and I want to push them into an array like this:
$data['something'] = 'whatever';
$data['hello'] = array();
$data['test'] = 123;
I was wondering if there was some sort of PHP function (similar to array_push()
) that can push a variable into an array, using the name of the variable as the key value?
Upvotes: 3
Views: 1263