我正在查看年度运营预算表。我有很多与单一年度运营预算相关的预算支出。我想在视图中列出这些费用。我如何为那些做一个foreach声明?
在我的AnnualOperatingBudgetController中:
public function view($id = null)
{
$annualOperatingBudget = $this->AnnualOperatingBudgets->get($id, [
'contain' => ['Azinstitutions', 'BudgetExpenses']
]);
$this->set('annualOperatingBudget', $annualOperatingBudget );
}
当我查看debugkit中的变量时,我可以看到它们。
annualOperatingBudget (array)
id 2
azinstitutions_id 2
budget_year 2015
assumptions
budget_expenses (array)
0 (App\Model\Entity\BudgetExpense)
1 (App\Model\Entity\BudgetExpense)
2 (App\Model\Entity\BudgetExpense)
3 (App\Model\Entity\BudgetExpense)
4 (App\Model\Entity\BudgetExpense)
5 (App\Model\Entity\BudgetExpense)
azinstitution (array)
[new] (false)
[accessible] (array)
[dirty] (empty)
[original] (empty)
[virtual] (empty)
[errors] (empty)
[invalid] (empty)
[repository] AnnualOperatingBudgets
但我无法使用
<?php foreach ($annualOperatingBudget as ?): ?>
只有一个。如何到达foreach的关联数组?
答案 0 :(得分:0)
如果void getPointsFromBezier(void *info, const CGPathElement *element){
NSMutableArray *bezierPoints = (__bridge NSMutableArray *)info;
CGPathElementType type = element->type;
CGPoint *points = element->points;
if (type != kCGPathElementCloseSubpath)
{
if ((type == kCGPathElementAddLineToPoint) ||
(type == kCGPathElementMoveToPoint))
[bezierPoints addObject:[NSValue valueWithCGPoint:points[0]]];
else if (type == kCGPathElementAddQuadCurveToPoint){
[bezierPoints addObject:[NSValue valueWithCGPoint:points[0]]];
[bezierPoints addObject:[NSValue valueWithCGPoint:points[1]]];
}else if (type == kCGPathElementAddCurveToPoint){
[bezierPoints addObject:[NSValue valueWithCGPoint:points[0]]];
[bezierPoints addObject:[NSValue valueWithCGPoint:points[1]]];
[bezierPoints addObject:[NSValue valueWithCGPoint:points[2]]];
}
}
是一个数组,您可以通过以下方式访问费用:
$annualOperatingBudget
如果是对象,则使用以下命令访问它们:
<?php foreach ($annualOperatingBudget['budget_expenses'] as $expense): ?>