$n = trim(fgets(STDIN)); for(0<=$i<$n){ [$s,$c] = trim(fgets(STDIN)); } for(0<=$i<8,$i=0,$i++){ $count = 0; if($c[$i] == 1) $count++; echo $count; }