I have an array defined as such:
<?php $Invoices = array();
foreach ($bookings as $booking){
$Invoices[$booking['id'] = $booking['invoice_no']];
}
?>
However, I'm getting a Notice (8): Undefined offset error
.
Currently, all $booking['id']
are identical to $booking['invoice_no']
- that will change; they're just test values for now (otherwise I would just stick to using $bookings
).
I plan to use the array for options in a form input:
<div class="col-sm-12">
<?= $this->Form->input('booking_id', ['class' => 'form-control',
'label' => 'Invoice Number', 'id' => 'booking_id', 'options' =>
$Invoices]); ?>
</div>
Checking my CakePHP 3 debugger, $bookings
definitely has sub arrays with elements - for example, $bookings[0]['id']
= $bookings[0]['invoice_no']
= 10.