Home >Backend Development >PHP Tutorial >请问在创建数组时如何将变量赋值给其中某个数组单元
$name = 123;
$data = array(
"userid" => $name,
"department" => [1, 2],
"position" => "产品经理",
"mobile" => "15913215421",
);
如上所示,可能是错误的,大概的意思就是那样
这样写没有错!
你想赋值到哪里
没有问题啊!
但是如果$name = "xyz" 赋值完后到底是 "userid" => xyz 还是 "userid" => "xyz"