大哥,打扰一下,php如何把一个数组中的键名合并到键值中?? 同时保持键名不变foreach ($k.$c as $cv) {echo $c;}foreach ($c[k].$c[v] as $c[v]) {echo $c;}都不对
<?php$test = array("key1"=>"value1","key2"=>"value2","key3"=>"value3");foreach($test as $key=>$value){ $test[$key] = $key.$value;}foreach($test as $key=>$value){ echo $key,":",$value,"<br/>";}?>将输出key1:key1value1key2:key2value2key3:key3value3
<?php$arr["tmp1"]="value1";$arr["tmp2"]="value2";foreach( $arr as $key => $val ){ $arr[$key] = $key . "|" . $val ; }print_r($arr);?>