Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下变量:
$something = 'whatever'; $hello = array(); $test = 123;
我想将它们推入这样的数组中:
$data['something'] = 'whatever'; $data['hello'] = array(); $data['test'] = 123;
我想知道是否有某种 PHP 函数(类似于array_push())可以将变量推入数组,使用变量的名称作为键值?
array_push()
就在这里。compact()会做到这一点。
compact()