日期:2014-05-16 浏览次数:20545 次
$tests=array(id => "910003", params => array("param1" => '', "param2" => '', "param3" => ''));
for ($i = 0; $i <= count($tests["params"]); $i++) {
}
$tests = array('id' => "910003", 'params' => array("param1" => '', "param2" => '', "param3" => ''));
foreach($tests["params"] as $k=>&$t) $t = $k;
print_r($tests);
Array
(
[id] => 910003
[params] => Array
(
[param1] => param1
[param2] => param2
[param3] => param3
)
)
$tests = array('id' => "910003", 'params' => array("param1" => '', "param2" => '', "param3" => ''));
for($i=1; $i<=count($tests["params"]); $i++) {
$tests["params"]['param'.$i] = $i;
}
print_r($tests);
Array
(
[id] => 910003
[params] => Array
(
[param1] => 1
[param2] => 2
[param3] => 3
)
)