$array = array();
给了我:
[0] => array {
}
但我想要那样:
["string"] => array {
}
......这真让我疯狂。
谢谢,亚历
答案 0 :(得分:10)
$array = array();
$array['string'] = "foo"; // this makes it so that $array['string'] = "foo"
$array[] = "bar"; // this makes it so that $array[0] = "bar"
$array[] = "barbar"; // this makes it so that $array[1] = "barbar"
print_r($array);
输出:
Array
(
[string] => foo
[0] => bar
[1] => barbar
)
希望这有帮助!
答案 1 :(得分:5)
答案 2 :(得分:1)
$ array = array(“string”=> array())