请问在创建数组时如何将变量赋值给其中某个数组单元
程序员文章站
2024-02-03 23:39:58
...
$name = 123;
$data = array(
"userid" => $name,
"department" => [1, 2],
"position" => "产品经理",
"mobile" => "15913215421",
);
如上所示,可能是错误的,大概的意思就是那样
$data = array(
"userid" => $name,
"department" => [1, 2],
"position" => "产品经理",
"mobile" => "15913215421",
);
如上所示,可能是错误的,大概的意思就是那样
回复讨论(解决方案)
这样写没有错!
你想赋值到哪里
没有问题啊!
但是如果$name = "xyz" 赋值完后到底是 "userid" => xyz 还是 "userid" => "xyz"