<?php

for ($i=1; $i<=12; $i++) {

$funcao = new DateTime("2018-".$i);

$numDias = $funcao->format('t');

echo $numDias."\n";

}