开发者

2 values in array, coding [closed]

开发者 https://www.devze.com 2023-03-28 18:21 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarify开发者_高级运维ing this question so that it can be reopened, visit the help center. Closed 11 years ago.

Like you can do:

$array = array("stuff" => $stuff);

Cant you do:

$array = array();

$array[] = "stuff" => $stuff;

How can I do something like that?


No, but you can do:

$array["stuff"] = $stuff;


What's wrong with:

$array = array( 'stuff' => $stuff );

or

$array            = array();
$array[ 'stuff' ] = $stuff;


You can define the key inside the [].

$array["stuff"] = $stuff;


Try $array["stuff"]=$stuff should work.


$array['stuff'] = $stuff;

is correct one

0

精彩评论

暂无评论...
验证码 换一张
取 消