我有這樣的代碼:循環在哪裏?
function filterVencimientos ($arrayFull) {
$filtered = array_filter($arrayFull, 'month');
var_dump($filtered);
return $filtered;
}
function month ($var) {
$response = false;
if (is_array($var)) {
foreach ($var as $item) {
$response = month($var);
}
} else {
$date = date('Y-m');
$response = (stripos($var, $date) !== false);
}
return $response;
}
function getFiltered() {
$arrayFull = getVencimientosPorPerfil();
$arrayFiltered = filterVencimientos($arrayFull);
return $arrayFiltered;
}
而返回此:
Fatal error: Out of memory (allocated 4194304) (tried to allocate 262144 bytes) in C:\xampp\htdocs\app\miramonteapp\api\yscript.php on line 244
我試圖去通過這個數組:
array(1) {
[258]=>
array(9) {
["recaudacion"]=>
array(13) {
[0]=>
string(10) "2017-01-07"
[1]=>
string(10) "2017-02-07"
}
["Contribuyentes Convenio Multilateral"]=>
array(13) {
[0]=>
string(10) "2017-01-13"
[1]=>
string(10) "2017-02-13"
}
}
}
哪裏是造成了圈外內存錯誤?
'的foreach($ var當成$項) {$ response = month($ var); }'你正在使用'$ var'而不是'$ item'。 –