#echo '<pre>';print_r($all_values);exit; #reset rule keys $statSum = $statSum + count($all_values); #echo '<pre>';print_r($all_values); $row = $kk + 3 + $addtoNextRow; #resources with statements, put an lines for more than 1 stat per rule $n = get_max_num_values($all_values, $rules) == 0 ? 1 : get_max_num_values($all_values, $rules); for ($m = 0; $m < $n; $m++) { ##Resource_id and notes in the first and seecond col $subrow = $row + $m; $worksheet->write($subrow, 0, $instances[$k]['resource_id']); $worksheet->write($subrow, 1, $instances[$k]['notes']); if (is_array($rules)) { foreach ($rules as $j => $value) { $rule_id = $rules[$j]['rule_id']; $values = get_value_by_rule($all_values, $rule_id); #echo $rule_id; #echo '<pre>';print_r($values); #show only the filename and not the values if ($values[$m]['file_name'] != '') { $worksheet->write($subrow, $j + 2, $values[$m]['file_name']); } elseif (ereg('<a href=(.*)>(.*)<\\/a>', $values[$m]['value'], $href)) { $worksheet->write($subrow, $j + 2, $href[1]); } else { $worksheet->write($subrow, $j + 2, $values[$m]['value']); } } } } $addtoNextRow = $addtoNextRow + $m - 1; $kk++;
function get_max_num_values($all_values, $rules) { $num_values = array(); if (is_array($rules)) { foreach ($rules as $i => $value) { array_push($num_values, count(get_value_by_rule($all_values, $rules[$i]['rule_id']))); } } #echo max($num_values)." "; if (count($num_values) >= 1) { return max($num_values); } }