Q:

access each object stored in an array

I just want to clear up how it is possible to use an object that is stored in an array? In Laravel I trigger a query.
$accounts = Account::where('customer_no', '=', $customer->customer_no)->get();

this returns two objects in an array here is a die and dump:
array(2) {
  [0]=>
   object(Account)#40 (5) {
 ["attributes"]=>
 array(11) {
  ["acc_no"]=>
  int(5)
  ["acc_type"]=>
  string(7) "CURRENT"
  ["start_date"]=>
  string(19) "2012-09-05 00:00:00"
  ["status"]=>
  int(1)
  ["balance"]=>
  string(5) "57.67"
  ["end_date"]=>
  NULL
  ["interest_rate"]=>
  string(4) "0.60"
  ["pin"]=>
  string(4) "1112"
  ["attempts"]=>
  int(2)
  ["bank_code"]=>
  int(1)
  ["customer_no"]=>
  int(10000003)
}
[1]=>
  object(Account)#43 (5) {
  ["attributes"]=>
  array(11) {
  ["acc_no"]=>
  int(6)
  ["acc_type"]=>
  string(7) "SAVINGS"
  ["start_date"]=>
  string(19) "2007-01-01 00:00:00"
  ["status"]=>
  int(1)
  ["balance"]=>
  string(7) "1002.01"
  ["end_date"]=>
  NULL
  ["interest_rate"]=>
  string(4) "0.80"
  ["pin"]=>
  string(4) "3427"
  ["attempts"]=>
  int(2)
  ["bank_code"]=>
  int(1)
  ["customer_no"]=>
  int(10000003)
}

So I want to access these objects individually so I can make use of them, instead of having to do a foreach to access them individually.
How can I store these objects independently in PHP?

A:

You can just grab the object from an array index.
$account_one = $accounts[0];
$account_two = $accounts[1];

Is there a reason you don't want to use a foreach though? You could also use a regular for loop and use $accounts[i] to refer to a specific account.

