如何提高foreach性能在php中

时间:2014-06-24 08:53:34

标签: php

我有两个数组

1)$ pcinput_array有3000条记录
2)$ compare_array有3.5个不严格的记录(取决于我的要求会增加)

foreach($compare_array as $key => $val){

$bRutgers = convertResult($val['results'],$val['snp']); //this array have 96 records

foreach($pcinput_array  as $inkey => $inval){
       $aRutgers = convertResult($inval['results'],$inval['snp']); //this array have 96 records

       $result_array = array_intersect_assoc($aRutger,$bRutger);        
       $total = count($result_array);
       if($totalMatched >= $this->allotherRutgersMatch)
       {
        $status = true;

       }

       if($status)
       {
            $result['status'] = '0';
            $pass[] = $val['ruid'];
       }
       else
       {
            $fail[] = $val['ruid'];
       }   

}

}


public function convertResult($value,$key)
    {
        $values = str_split($value);
        $keys = explode(',',$key);
        //$results = $this->safeArrayCombine($keys, $values);
        $results = array_combine($keys,$values);
        return $results;
    }

虽然运行此编码我的PHP服务器冻结,也需要3至4小时。我需要提高性能。如何提高性能。请帮我。我过去两周都在挣扎。

谢谢, Sivanesan.v

0 个答案:

没有答案