PHP怎样两个数组 循环除以?
数组1foreach($dbas$v){$v['money'];}数组2foreach($dbas$v){$v['qian'];}循环除以怎么写?>$v['money']...
数组1
foreach($db as $v){
$v['money'];
}
数组2
foreach($db as $v){
$v['qian'];
}
循环除以怎么写?>
$v['money']/ $v['qian']
array1 =array([id]=>11 [id]=> 22[id]=> 33[id]=> 44[id]=> 88 [id]=> 99[id]=> 88[id]=> 11[id]=> 22);
array2= array([id]=>11 [id]=> 22[id]=> 33[id]=> 44[id]=> 88 [id]=> 99[id]=> 88[id]=> 11[id]=> 22);
foreach( ??? as $v){
echo $jieguo= (array1=$v['id'] / array2=$v['id'] );
} 展开
foreach($db as $v){
$v['money'];
}
数组2
foreach($db as $v){
$v['qian'];
}
循环除以怎么写?>
$v['money']/ $v['qian']
array1 =array([id]=>11 [id]=> 22[id]=> 33[id]=> 44[id]=> 88 [id]=> 99[id]=> 88[id]=> 11[id]=> 22);
array2= array([id]=>11 [id]=> 22[id]=> 33[id]=> 44[id]=> 88 [id]=> 99[id]=> 88[id]=> 11[id]=> 22);
foreach( ??? as $v){
echo $jieguo= (array1=$v['id'] / array2=$v['id'] );
} 展开
1个回答
展开全部
<?php
$arr1 = array( 2, 4, 6, 8, 10);
$arr2 = array( 2, 4, 6, 8, 10);
$num = count($arr1);//个数
$arr_new = array(); //空数组,存放相除后的结果
for($i=0; $i<$num; $i++){
$arr_new[] = $arr1[$i]/$arr2[$i];
}
print_r($arr_new);
?>
$arr1 = array( 2, 4, 6, 8, 10);
$arr2 = array( 2, 4, 6, 8, 10);
$num = count($arr1);//个数
$arr_new = array(); //空数组,存放相除后的结果
for($i=0; $i<$num; $i++){
$arr_new[] = $arr1[$i]/$arr2[$i];
}
print_r($arr_new);
?>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询