Calculate the highest duplicate integers of two associative arrays

后端 未结 4 1739
清歌不尽
清歌不尽 2021-01-25 11:19

Given 2 associative arrays:

$fruits  = array ( \"d\" => \"lemon\", \"a\" => \"orange\", \"b\" => \"banana\", \"c\" => \"apple\" );
$fruits2 = array          


        
4条回答
  •  花落未央
    2021-01-25 12:04

    Got it working this way :

    $n = count($fruits);
    for ( $i = 0; $i < $n; $i++)
    {
      $cur_vals_1 = each ($fruits);
      $cur_vals_2 = each ($fruits2);
    
      $sum1 += $cur_vals_1['key'] * $cur_vals_1['value'];
    
      ...
    }
    

提交回复
热议问题