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
精彩评论