php中怎样自定义函数改变数组的值?

2024-12-20 03:39:07
推荐回答(1个)
回答1:

传引用即可,例子代码:

$table_exchange=array(1,2,3,4,5,6,7,8);
NumChange($table_exchange);
print_r($table_exchange);
echo $table_exchange[0];

function NumChange(&$num){
foreach ($num as $b=>$c){
$num[$b]="Week_".$c;
}
}
?>