2
I have a code that takes all the dates of a particular day of the week.
Ex. 5/06/2017 = Monday.
The code is working perfectly. But it is limited only 1 day of the week, I would like to "spend" more days an array.
function dias($dia_semana, $mes, $ano)
{
$date = new DateTime();
$dias = cal_days_in_month(CAL_GREGORIAN, $mes, $ano);
for ($dia = 0; $dia <= $dias; $dia++)
{
$date->setDate( $ano, $mes, $dia );
if ($date->format( "w" ) == $dia_semana)
{
$datas[] = $dia."/".$mes."/".$ano;
}
}
return $datas;
}
print_r(dias("1","06","2017");
// "1" = 0 = domingo até o 6 = Sábado
// "06" = mês
// "2017" = Ano
I wanted to spend a array
in place of $dia_semana
perfect friend, thanks for the answer. I will adapt with what precise, bad initially was this the problem.
– Mustache Web
For nothing, needing we are here! hehe
– Kayo Bruno
Raapaz, now a question, if not to pass an array returns an error. How I treat this to bring the result, regardless of whether it is array or string?
– Mustache Web
In PHP there is the "is_array" function you use it to check if the received value is an array, then you just do the remaining processing.
– Kayo Bruno
Heheheeh thanks again !
– Mustache Web