how to traverse the array and filter all except the current month?
example:
i have this:
array(1) {
[257]=>
array(10) {
["recaudacion"]=>
array(13) {
[0]=>
string(10) "2017-01-07"
[1]=>
string(10) "2017-02-07"
[2]=>
string(10) "2017-03-07"
[3]=>
string(10) "2017-04-07"
[4]=>
string(10) "2017-05-07"
[5]=>
string(10) "2017-06-07"
[6]=>
string(10) "2017-07-07"
[7]=>
string(10) "2017-08-07"
[8]=>
string(10) "2017-09-07"
[9]=>
string(10) "2017-10-07"
[10]=>
string(10) "2017-11-07"
[11]=>
string(10) "2017-12-07"
[12]=>
string(10) "2018-01-07"
}
["Contribuyentes Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "2017-01-13"
[1]=>
string(10) "2017-02-13"
[2]=>
string(10) "2017-03-13"
[3]=>
string(10) "2017-04-17"
[4]=>
string(10) "2017-05-15"
[5]=>
string(10) "2017-06-13"
[6]=>
string(10) "2017-07-13"
[7]=>
string(10) "2017-08-14"
[8]=>
string(10) "2017-09-13"
[9]=>
string(10) "2017-10-13"
[10]=>
string(10) "2017-11-13"
[11]=>
string(10) "2017-12-13"
[12]=>
string(10) "2018-01-13"
}
["Contribuyentes Locales,Activid. Especiales y Salas de Recreacion"]=>
array(13) {
[0]=>
string(10) "2017-01-16"
[1]=>
string(10) "2017-02-15"
[2]=>
string(10) "2017-03-15"
[3]=>
string(10) "2017-04-17"
[4]=>
string(10) "2017-05-15"
[5]=>
string(10) "2017-06-15"
[6]=>
string(10) "2017-07-17"
[7]=>
string(10) "2017-08-16"
[8]=>
string(10) "2017-09-15"
[9]=>
string(10) "2017-10-16"
[10]=>
string(10) "2017-11-15"
[11]=>
string(10) "2017-12-15"
[12]=>
string(10) "2018-01-16"
}
["Regimen simplificado"]=>
array(13) {
[0]=>
string(10) "2017-01-20"
[1]=>
string(10) "2017-02-00"
[2]=>
string(10) "2017-03-20"
[3]=>
string(10) "2017-04-00"
[4]=>
string(10) "2017-05-22"
[5]=>
string(10) "2017-06-00"
[6]=>
string(10) "2017-07-20"
[7]=>
string(10) "2017-08-00"
[8]=>
string(10) "2017-09-20"
[9]=>
string(10) "2017-10-00"
[10]=>
string(10) "2017-11-20"
[11]=>
string(10) "2017-12-00"
[12]=>
string(10) "2018-01-20"
}
["Declaracion Jurada Fiscal 2016 Contibuyentes Locales"]=>
array(13) {
[0]=>
string(10) "2017-01-00"
[1]=>
string(10) "2017-02-00"
[2]=>
string(10) "2017-03-00"
[3]=>
string(10) "2017-04-00"
[4]=>
string(10) "2017-05-00"
[5]=>
string(10) "2017-06-00"
[6]=>
string(10) "2017-07-00"
[7]=>
string(10) "2017-08-00"
[8]=>
string(10) "2017-09-00"
[9]=>
string(10) "2017-10-00"
[10]=>
string(10) "2017-11-00"
[11]=>
string(10) "2017-12-00"
[12]=>
string(10) "2018-01-00"
}
["Recategorizacion cuatrimestral regimen simplificado"]=>
array(13) {
[0]=>
string(11) "2017-01-131"
[1]=>
string(10) "2017-02-00"
[2]=>
string(10) "2017-03-00"
[3]=>
string(10) "2017-04-00"
[4]=>
string(11) "2017-05-131"
[5]=>
string(10) "2017-06-00"
[6]=>
string(10) "2017-07-00"
[7]=>
string(10) "2017-08-00"
[8]=>
string(11) "2017-09-130"
[9]=>
string(10) "2017-10-00"
[10]=>
string(10) "2017-11-00"
[11]=>
string(10) "2017-12-00"
[12]=>
string(11) "2018-01-131"
}
["Declaracion Jurada anual 2016 Contribuyentes de convenio multilateral"]=>
array(13) {
[0]=>
string(10) "2017-01-00"
[1]=>
string(10) "2017-02-00"
[2]=>
string(10) "2017-03-00"
[3]=>
string(10) "2017-04-00"
[4]=>
string(10) "2017-05-00"
[5]=>
string(10) "2017-06-30"
[6]=>
string(10) "2017-07-00"
[7]=>
string(10) "2017-08-00"
[8]=>
string(10) "2017-09-00"
[9]=>
string(10) "2017-10-00"
[10]=>
string(10) "2017-11-00"
[11]=>
string(10) "2017-12-00"
[12]=>
string(10) "2018-01-00"
}
["Impuestos de Sellos"]=>
array(13) {
[0]=>
string(10) "2017-01-10"
[1]=>
string(10) "2017-02-10"
[2]=>
string(10) "2017-03-10"
[3]=>
string(10) "2017-04-10"
[4]=>
string(10) "2017-05-10"
[5]=>
string(10) "2017-06-10"
[6]=>
string(10) "2017-07-10"
[7]=>
string(10) "2017-08-10"
[8]=>
string(10) "2017-09-10"
[9]=>
string(10) "2017-10-10"
[10]=>
string(10) "2017-11-10"
[11]=>
string(10) "2017-12-10"
[12]=>
string(10) "2018-01-10"
}
["Ingresos Brutos Contribuyentes Locales"]=>
array(13) {
[0]=>
string(10) "21/02/2017"
[1]=>
string(10) "21/03/2017"
[2]=>
string(10) "19/04/2017"
[3]=>
string(10) "19/05/2017"
[4]=>
string(10) "21/06/2017"
[5]=>
string(10) "19/07/2017"
[6]=>
string(10) "22/08/2017"
[7]=>
string(10) "19/09/2017"
[8]=>
string(10) "19/10/2017"
[9]=>
string(10) "21/11/2017"
[10]=>
string(10) "19/12/2017"
[11]=>
string(10) "19/01/2018"
[12]=>
string(10) "04/04/2017"
}
["Ingresos Brutos de Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "13/02/2017"
[1]=>
string(10) "13/03/2017"
[2]=>
string(10) "17/04/2017"
[3]=>
string(10) "15/05/2017"
[4]=>
string(10) "13/06/2017"
[5]=>
string(10) "13/07/2017"
[6]=>
string(10) "14/08/2017"
[7]=>
string(10) "13/09/2017"
[8]=>
string(10) "13/10/2017"
[9]=>
string(10) "13/11/2017"
[10]=>
string(10) "13/12/2017"
[11]=>
string(10) "15/01/2018"
[12]=>
string(10) "30/06/2017"
}
}
}
array(1) {
[258]=>
array(10) {
["recaudacion"]=>
array(13) {
[0]=>
string(10) "2017-01-07"
[1]=>
string(10) "2017-02-07"
[2]=>
string(10) "2017-03-07"
[3]=>
string(10) "2017-04-07"
[4]=>
string(10) "2017-05-07"
[5]=>
string(10) "2017-06-07"
[6]=>
string(10) "2017-07-07"
[7]=>
string(10) "2017-08-07"
[8]=>
string(10) "2017-09-07"
[9]=>
string(10) "2017-10-07"
[10]=>
string(10) "2017-11-07"
[11]=>
string(10) "2017-12-07"
[12]=>
string(10) "2018-01-07"
}
["Contribuyentes Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "2017-01-13"
[1]=>
string(10) "2017-02-13"
[2]=>
string(10) "2017-03-13"
[3]=>
string(10) "2017-04-17"
[4]=>
string(10) "2017-05-15"
[5]=>
string(10) "2017-06-13"
[6]=>
string(10) "2017-07-13"
[7]=>
string(10) "2017-08-14"
[8]=>
string(10) "2017-09-13"
[9]=>
string(10) "2017-10-13"
[10]=>
string(10) "2017-11-13"
[11]=>
string(10) "2017-12-13"
[12]=>
string(10) "2018-01-13"
}
["Contribuyentes Locales,Activid. Especiales y Salas de Recreacion"]=>
array(13) {
[0]=>
string(10) "2017-01-17"
[1]=>
string(10) "2017-02-16"
[2]=>
string(10) "2017-03-16"
[3]=>
string(10) "2017-04-18"
[4]=>
string(10) "2017-05-16"
[5]=>
string(10) "2017-06-16"
[6]=>
string(10) "2017-07-18"
[7]=>
string(10) "2017-08-17"
[8]=>
string(10) "2017-09-18"
[9]=>
string(10) "2017-10-17"
[10]=>
string(10) "2017-11-16"
[11]=>
string(10) "2017-12-18"
[12]=>
string(10) "2018-01-17"
}
["Regimen simplificado"]=>
array(13) {
[0]=>
string(10) "2017-01-23"
[1]=>
string(10) "2017-02-00"
[2]=>
string(10) "2017-03-21"
[3]=>
string(10) "2017-04-00"
[4]=>
string(10) "2017-05-23"
[5]=>
string(10) "2017-06-00"
[6]=>
string(10) "2017-07-21"
[7]=>
string(10) "2017-08-00"
[8]=>
string(10) "2017-09-21"
[9]=>
string(10) "2017-10-00"
[10]=>
string(10) "2017-11-21"
[11]=>
string(10) "2017-12-00"
[12]=>
string(10) "2018-01-23"
}
["Declaracion Jurada Fiscal 2016 Contibuyentes Locales"]=>
array(13) {
[0]=>
string(10) "2017-01-00"
[1]=>
string(10) "2017-02-00"
[2]=>
string(10) "2017-03-00"
[3]=>
string(10) "2017-04-00"
[4]=>
string(10) "2017-05-00"
[5]=>
string(10) "2017-06-00"
[6]=>
string(10) "2017-07-00"
[7]=>
string(10) "2017-08-00"
[8]=>
string(10) "2017-09-00"
[9]=>
string(10) "2017-10-00"
[10]=>
string(10) "2017-11-00"
[11]=>
string(10) "2017-12-00"
[12]=>
string(10) "2018-01-00"
}
["Recategorizacion cuatrimestral regimen simplificado"]=>
array(13) {
[0]=>
string(11) "2017-01-131"
[1]=>
string(10) "2017-02-00"
[2]=>
string(10) "2017-03-00"
[3]=>
string(10) "2017-04-00"
[4]=>
string(11) "2017-05-131"
[5]=>
string(10) "2017-06-00"
[6]=>
string(10) "2017-07-00"
[7]=>
string(10) "2017-08-00"
[8]=>
string(11) "2017-09-130"
[9]=>
string(10) "2017-10-00"
[10]=>
string(10) "2017-11-00"
[11]=>
string(10) "2017-12-00"
[12]=>
string(11) "2018-01-131"
}
["Declaracion Jurada anual 2016 Contribuyentes de convenio multilateral"]=>
array(13) {
[0]=>
string(10) "2017-01-00"
[1]=>
string(10) "2017-02-00"
[2]=>
string(10) "2017-03-00"
[3]=>
string(10) "2017-04-00"
[4]=>
string(10) "2017-05-00"
[5]=>
string(10) "2017-06-30"
[6]=>
string(10) "2017-07-00"
[7]=>
string(10) "2017-08-00"
[8]=>
string(10) "2017-09-00"
[9]=>
string(10) "2017-10-00"
[10]=>
string(10) "2017-11-00"
[11]=>
string(10) "2017-12-00"
[12]=>
string(10) "2018-01-00"
}
["Impuestos de Sellos"]=>
array(13) {
[0]=>
string(10) "2017-01-10"
[1]=>
string(10) "2017-02-10"
[2]=>
string(10) "2017-03-10"
[3]=>
string(10) "2017-04-10"
[4]=>
string(10) "2017-05-10"
[5]=>
string(10) "2017-06-10"
[6]=>
string(10) "2017-07-10"
[7]=>
string(10) "2017-08-10"
[8]=>
string(10) "2017-09-10"
[9]=>
string(10) "2017-10-10"
[10]=>
string(10) "2017-11-10"
[11]=>
string(10) "2017-12-10"
[12]=>
string(10) "2018-01-10"
}
["Ingresos Brutos Contribuyentes Locales"]=>
array(13) {
[0]=>
string(10) "22/02/2017"
[1]=>
string(10) "22/03/2017"
[2]=>
string(10) "20/04/2017"
[3]=>
string(10) "22/05/2017"
[4]=>
string(10) "22/06/2017"
[5]=>
string(10) "20/07/2017"
[6]=>
string(10) "23/08/2017"
[7]=>
string(10) "20/09/2017"
[8]=>
string(10) "20/10/2017"
[9]=>
string(10) "22/11/2017"
[10]=>
string(10) "20/12/2017"
[11]=>
string(10) "22/01/2018"
[12]=>
string(10) "05/04/2017"
}
["Ingresos Brutos de Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "13/02/2017"
[1]=>
string(10) "13/03/2017"
[2]=>
string(10) "17/04/2017"
[3]=>
string(10) "15/05/2017"
[4]=>
string(10) "13/06/2017"
[5]=>
string(10) "13/07/2017"
[6]=>
string(10) "14/08/2017"
[7]=>
string(10) "13/09/2017"
[8]=>
string(10) "13/10/2017"
[9]=>
string(10) "13/11/2017"
[10]=>
string(10) "13/12/2017"
[11]=>
string(10) "15/01/2018"
[12]=>
string(10) "30/06/2017"
}
}
}
and i want this:
array(1) {
[257]=>
array(10) {
["recaudacion"]=>
array(13) {
[0]=>
string(10) "2017-10-07"
}
["Contribuyentes Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "2017-10-13"
}
["Contribuyentes Locales,Activid. Especiales y Salas de Recreacion"]=>
array(13) {
[0]=>
string(10) "2017-10-16"
}
["Regimen simplificado"]=>
array(13) {
[0]=>
string(10) "2017-10-00"
}
["Declaracion Jurada Fiscal 2016 Contibuyentes Locales"]=>
array(13) {
[0]=>
string(10) "2017-10-00"
}
["Recategorizacion cuatrimestral regimen simplificado"]=>
array(13) {
[0]=>
string(10) "2017-10-00"
}
["Declaracion Jurada anual 2016 Contribuyentes de convenio multilateral"]=>
array(13) {
[0]=>
string(10) "2017-10-00"
}
["Impuestos de Sellos"]=>
array(13) {
[0]=>
string(10) "2017-10-10"
}
["Ingresos Brutos Contribuyentes Locales"]=>
array(13) {
[0]=>
string(10) "19/10/2017"
}
["Ingresos Brutos de Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "13/10/2017"
}
}
}
array(1) {
[258]=>
array(10) {
["recaudacion"]=>
array(13) {
[0]=>
string(10) "2017-10-07"
}
["Contribuyentes Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "2017-10-13"
}
["Contribuyentes Locales,Activid. Especiales y Salas de Recreacion"]=>
array(13) {
[0]=>
string(10) "2017-10-17"
}
["Regimen simplificado"]=>
array(13) {
[0]=>
string(10) "2017-10-00"
}
["Declaracion Jurada Fiscal 2016 Contibuyentes Locales"]=>
array(13) {
[0]=>
string(10) "2017-10-00"
}
["Recategorizacion cuatrimestral regimen simplificado"]=>
array(13) {
[0]=>
string(10) "2017-10-00"
}
["Declaracion Jurada anual 2016 Contribuyentes de convenio multilateral"]=>
array(13) {
[0]=>
string(10) "2017-10-00"
}
["Impuestos de Sellos"]=>
array(13) {
[0]=>
string(10) "2017-10-10"
}
["Ingresos Brutos Contribuyentes Locales"]=>
array(13) {
[0]=>
string(10) "20/10/2017"
}
["Ingresos Brutos de Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "13/10/2017"
}
}
}
I do not care about the day but it must be kept.
my code here:
function filtrarVencimientos($arrayCompleto){
$filtered = array_filter($arrayCompleto, 'month');
var_dump($filtered);
return $filtered;
}
function month($outer) {
$dt = new \DateTime;
$current_month = $dt->format('Y-m');
foreach ($outer as &$middle) {
foreach ($middle as &$inner) {
foreach ($inner as &$item) {
if (date_format($item, 'Y-m') == $current_month) {
unset($item);
}
return $item;
}
}
}
}
function getFiltrado(){
$arrayCompleto = getVencimientosPorPerfil();
$arrayFiltrado = filtrarVencimientos($arrayCompleto);
return $arrayFiltrado;
}
I tried using stripos but it does not support arrays and I could not think of a way to do it ... any ideas?
I edited the question by adding my code and the complete result of the original array