php - increment in array -
i have earlier asked question mistake, deleted question reposting question.
if (isset($_request['receipts'])) { $params['date'] = '31 jan 2000'; $response = $auth->request('get', $auth->url('receipts/travel', 'core'), $params); if ($auth->response['code'] == 200) { $receipt = $auth->parseresponse($oauth->response['response'], $auth->response['format']); pr($receipt->receipts); } else { outputerror($auth); }
}
this piece of code provides me travel receipts on 31 jan 2000 , wanted include foreach loop travel receipts whole 12 months of 2000 28 feb 2000, 31 mar 2000 , on till 31 dec 2000.
i beginner , hence tried following basic foreach loop didnt work know misplaced logic.
if (isset($_request['receipts'])) { $months = array( " 31 jan 2000"," 28 feb 2000"," 31 mar 2000","30 apr 2000","31 may 2000","30 jun 2000","31 jul 2000"," 31 aug 2000","30 sep 2000","31 oct 2000","30 nov 2000","31 dec 2000"); foreach ($months $month){ $params['date'] = '31 jan 2000'; $response = $auth->request('get', $auth->url('receipts/travel', 'core'), $params); if ($auth->response['code'] == 200) { $receipt = $auth->parseresponse($oauth->response['response'], $auth->response['format']); pr($receipt->receipts); } else { outputerror($auth); } }
}
i know pretty basic as concerned big issue , on case highly helpful me. thanks
hi, there way instead of directly storing month values[ 31 jan 2000"," 28 feb 2000"," 31 mar 2000"...] in array, code should increment different months. because providing month values of year kind of hardcoding , other years need edit often. ideas on this?
you used foreach
must've forgot plug $params
variable.
foreach ($months $month){ $params['date'] = $month; ... }
does solve problem?
Comments
Post a Comment