Optimizing array merge operation

后端 未结 3 1095
耶瑟儿~
耶瑟儿~ 2021-01-19 09:52

I would appreciate any help, given.

I have 7 separate arrays with approx. 90,000 numbers in each array (let\'s call them arrays1-arrays7). There are no duplicate num

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-19 10:54

    I suggest replacing

    foreach($result as $key => $val)
    {
        if($result[$key]==3)
        {
        fwrite($fp_lines, $key."\r\n");
        }
    }
    

    With something like

    $res = array_keys(array_filter($result, function($val){return $val == 3;}));
    fwrite($fp_lines, implode("\r\n", $res));
    

提交回复
热议问题