请问在创建数组时如何将变量赋值给其中某个数组单元

WBOY
Release: 2016-06-20 12:33:45
Original
949 people have browsed it

$name = 123;
$data = array(
         "userid" => $name,
         "department" => [1, 2],
         "position" => "产品经理",
         "mobile" => "15913215421",
      );

如上所示,可能是错误的,大概的意思就是那样


回复讨论(解决方案)

这样写没有错!

你想赋值到哪里

没有问题啊!

但是如果$name = "xyz"    赋值完后到底是  "userid" => xyz 还是 "userid" => "xyz"

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template