$b) { if(isset($out[$a])) $out[$a] += $b; else $out[$a] = $b; } continue; } $ext = pathinfo($file, PATHINFO_EXTENSION); if(!in_array($ext, ['php', 'less', 'ts', 'tsx', 'twig'])) continue; if($ext === 'tsx') $ext = 'ts'; if(!isset($out[$ext])) $out[$ext] = 0; $out[$ext] += count(file($file)); } return $out; } $out = collect_extensions($path); arsort($out); foreach($out as $language => $lines) echo "{$language}:\t" . number_format($lines) . " lines\r\n";