【发布时间】:2014-01-15 09:19:24
【问题描述】:
$input = "hello|world|look|at|this";
$explode = explode("|", $input);
$array = array("Title" => "Hello!", "content" => $explode);
这将输出:
array(2) {
["Title"]=>
string(6) "Hello!"
["content"]=>
array(5) {
[0]=>
string(5) "hello"
[1]=>
string(5) "world"
[2]=>
string(4) "look"
[3]=>
string(2) "at"
[4]=>
string(4) "this"
}
}
但我希望它们成为具有 NULL 作为值的键,因为我在后面的步骤中添加值。
知道如何让explode() 函数作为键返回吗? php 有没有可用的功能?
【问题讨论】:
-
array_fill_keys() 当您首先创建数组时