用for给数组赋值
程序员文章站
2024-02-10 23:03:40
...
$tests=array(id => "910003", params => array("param1" => '', "param2" => '', "param3" => ''));for ($i = 0; $i
如何用上述方法修改param1,param2,param3值?
回复讨论(解决方案)
$i 应为
$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; $iArray( [id] => 910003 [params] => Array ( [param1] => 1 [param2] => 2 [param3] => 3 ))谢谢!,如果这个参数名是没有规律的(如:param_23、paramAbc……),那有如何实现
不是给了你两个方案了吗?
哦,明白了!谢谢!
$tests=array('id' => "910003", 'params' => array( "param1" => '', "param2" => '', "param3" => '' ));for ($i = 1; $i
谢谢!,如果这个参数名是没有规律的(如:param_23、paramAbc……),那有如何实现
如果没有规律,只能换一种办法了
上一篇: 如何拿到id删除这个商品
下一篇: php下载远程文件类支持断点续传