title: PHP Object with array of objects finding key/value and linking it with another key/value pair
body: <p><strong>PROGRESS:</strong> Almost there... Need help on the last bit!!!</p>
  
  <pre><code>$users = $client-&gt;getAccounts();
  
  
  $num = count($users);
  for ( $x=0; $x &lt; $num; $x++){
      foreach($users[$x] as $y =&gt; $y_value) {
          if($y_value == iLy){
              print_r($y);
              echo '&lt;br&gt;';
              print_r($x);
              echo '&lt;br&gt;';
              print_r($user[$x]["id"]);
          }
      }
  }
  </code></pre>
  
  <p>Above is the latest bit of code I have written and I have been to locate the array value or the array I am looking for by search by name. <code>print_r($user[$x]["id"]);
  </code>
  Results in:</p>
  
  <pre><code>Warning: Illegal string offset 'id' in /home/examplesite/BLANK.com/CBapi.php on line 37
  </code></pre>
  
  <p>I used this simplification to discover the logic for my solution:
  <strong>This works</strong></p>
  
  <pre><code>&lt;?php
  $age = array (array("name"=&gt;"iLy", "id"=&gt;"37", "balance"=&gt;"43"),
                array("name"=&gt;"jim", "id"=&gt;"67", "balance"=&gt;"47"));
  
  echo $age[0]['id'];
  
  $num = count($age);
  for ( $x=0; $x &lt; $num; $x++){
      foreach($age[$x] as $y =&gt; $y_value) {
          if($y_value == 43){
              print_r($y);
              echo '&lt;br&gt;';
              print_r($x);
              echo '&lt;br&gt;';
              print_r($age[$x]["id"]);
  
          }
      }
  }
  ?&gt;
  </code></pre>
  
  <p>I believe I am just calling the wrong Key Name. <br>
  ++++++++++++++++++++++ <strong>Original Post Below</strong> ++++++++++++++++++++++</p>
  
  <p>Current code:</p>
  
  <pre><code>$configuration = Configuration::apiKey($apiKey, $apiSecret);
  $configuration-&gt;setApiUrl(Configuration::SANDBOX_API_URL); 
  $client = Client::create($configuration);
  
  $users = $client-&gt;getAccounts();
  </code></pre>
  
  <p>I have been struggling with this for four days now... I used function below and it returns an object which contains an array of objects. My goal is to search through the collection of objects for a key and value, (For example to search the name of a current user:<code>$currentuser = 'iLy'; $user = $currentuser;</code> Then I could identify the array value, which would be  <code>$users[2]</code> for our example 'iLy' to search the key value 'id', to get the $accountId.</p>
  
  <p>Ideally I could search 'name' => iLy and have it return the 'id' => 'xxxxxxx' in that same array.</p>
  
  <p>When I create accounts this is the only way I have been able to figure out how to get the accountID, and I haven't found any other API calls to get the account by name. I have only been able to isolate one object using <code>$users[2]</code>. I know this may be a repeat post, but I haven't been able to make any of the other solutions work.
  <a href="https://stackoverflow.com/questions/4742903/php-find-entry-by-object-property-from-a-array-of-objects">PHP - find entry by object property from a array of objects</a> , <a href="https://stackoverflow.com/questions/8612190/array-of-php-objects/8612289">Array of PHP Objects</a></p>
  
  <p>Maybe I am using the wrong solutions or applying them wrong. Any help would be greatly appreciated!</p>
  
  <pre><code>public function getAccounts(array $params = [])
  {
      return $this-&gt;getAndMapCollection('/v2/accounts',$params,'toAccounts');                           
  }
  </code></pre>
  
  <p>Returns this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    
  
  Coinbase\\Wallet\\Resource\\ResourceCollection Object (
  [previousUri:Coinbase\\Wallet\\Resource\\ResourceCollection:private] =&gt;
  [nextUri:Coinbase\\Wallet\\Resource\\ResourceCollection:private] =&gt;
  [resources:Coinbase\\Wallet\\Resource\\ResourceCollection:private] =&gt; Array (
  [0] =&gt; Coinbase\\Wallet\\Resource\\Account Object (
  [name:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Jennaod3
  [primary:Coinbase\\Wallet\\Resource\\Account:private] =&gt;
  [type:Coinbase\\Wallet\\Resource\\Account:private] =&gt; wallet
  [currency:Coinbase\\Wallet\\Resource\\Account:private] =&gt; BTC
  [balance:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Coinbase\\Wallet\\Value\\Money Object (
  [amount:Coinbase\\Wallet\\Value\\Money:private] =&gt; 0.00000000
  [currency:Coinbase\\Wallet\\Value\\Money:private] =&gt; BTC
  )
  [nativeBalance:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Coinbase\\Wallet\\Value\\Money Object (
  [amount:Coinbase\\Wallet\\Value\\Money:private] =&gt; 0.00
  [currency:Coinbase\\Wallet\\Value\\Money:private] =&gt; USD
  )
  [createdAt:Coinbase\\Wallet\\Resource\\Account:private] =&gt; DateTime Object (
  [date] =&gt; 2016-05-24 04:55:41.000000
  [timezone_type] =&gt; 2
  [timezone] =&gt; Z
  )
  [updatedAt:Coinbase\\Wallet\\Resource\\Account:private] =&gt; DateTime Object (
  [date] =&gt; 2016-05-24 04:55:41.000000
  [timezone_type] =&gt; 2
  [timezone] =&gt; Z
  )
  [id:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; 0d41fc45-0a53-58cb-9931-c9a33f520963
  [resource:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; account
  [resourcePath:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; /v2/accounts/0d41fc45-0a53-58cb-9931-c9a33f520963
  [rawData:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; Array (
  [id] =&gt; 0d41fc45-0a53-58cb-9931-c9a33f520963
  [name] =&gt; Jennaod3
  [primary] =&gt;
  [type] =&gt; wallet
  [currency] =&gt; BTC
  [balance] =&gt; Array (
  [amount] =&gt; 0.00000000
  [currency] =&gt; BTC
  )
  [native_balance] =&gt; Array (
  [amount] =&gt; 0.00
  [currency] =&gt; USD
  )
  [created_at] =&gt; 2016-05-24T04:55:41Z
  [updated_at] =&gt; 2016-05-24T04:55:41Z
  [resource] =&gt; account
  [resource_path] =&gt; /v2/accounts/0d41fc45-0a53-58cb-9931-c9a33f520963
  )
  )
  [1] =&gt; Coinbase\\Wallet\\Resource\\Account Object (
  [name:Coinbase\\Wallet\\Resource\\Account:private] =&gt; jenna works to
  [primary:Coinbase\\Wallet\\Resource\\Account:private] =&gt;
  [type:Coinbase\\Wallet\\Resource\\Account:private] =&gt; wallet
  [currency:Coinbase\\Wallet\\Resource\\Account:private] =&gt; BTC
  [balance:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Coinbase\\Wallet\\Value\\Money Object (
  [amount:Coinbase\\Wallet\\Value\\Money:private] =&gt; 0.00000000
  [currency:Coinbase\\Wallet\\Value\\Money:private] =&gt; BTC
  )
  [nativeBalance:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Coinbase\\Wallet\\Value\\Money Object (
  [amount:Coinbase\\Wallet\\Value\\Money:private] =&gt; 0.00
  [currency:Coinbase\\Wallet\\Value\\Money:private] =&gt; USD
  )
  [createdAt:Coinbase\\Wallet\\Resource\\Account:private] =&gt; DateTime Object (
  [date] =&gt; 2016-05-22 13:37:16.000000
  [timezone_type] =&gt; 2
  [timezone] =&gt; Z
  )
  [updatedAt:Coinbase\\Wallet\\Resource\\Account:private] =&gt; DateTime Object (
  [date] =&gt; 2016-05-22 13:37:16.000000
  [timezone_type] =&gt; 2
  [timezone] =&gt; Z
  )
  [id:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; e7ab48b4-bc76-513a-a78b-6d627f32f848
  [resource:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; account
  [resourcePath:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; /v2/accounts/e7ab48b4-bc76-513a-a78b-6d627f32f848
  [rawData:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; Array (
  [id] =&gt; e7ab48b4-bc76-513a-a78b-6d627f32f848
  [name] =&gt; jenna works to
  [primary] =&gt;
  [type] =&gt; wallet
  [currency] =&gt; BTC
  [balance] =&gt; Array (
  [amount] =&gt; 0.00000000
  [currency] =&gt; BTC
  )
  [native_balance] =&gt; Array (
  [amount] =&gt; 0.00
  [currency] =&gt; USD
  )
  [created_at] =&gt; 2016-05-22T13:37:16Z
  [updated_at] =&gt; 2016-05-22T13:37:16Z
  [resource] =&gt; account
  [resource_path] =&gt; /v2/accounts/e7ab48b4-bc76-513a-a78b-6d627f32f848
  )
  )
  [2] =&gt; Coinbase\\Wallet\\Resource\\Account Object (
  [name:Coinbase\\Wallet\\Resource\\Account:private] =&gt; iLy
  [primary:Coinbase\\Wallet\\Resource\\Account:private] =&gt;
  [type:Coinbase\\Wallet\\Resource\\Account:private] =&gt; wallet
  [currency:Coinbase\\Wallet\\Resource\\Account:private] =&gt; BTC
  [balance:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Coinbase\\Wallet\\Value\\Money Object (
  [amount:Coinbase\\Wallet\\Value\\Money:private] =&gt; 0.00000000
  [currency:Coinbase\\Wallet\\Value\\Money:private] =&gt; BTC
  )
  [nativeBalance:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Coinbase\\Wallet\\Value\\Money Object (
  [amount:Coinbase\\Wallet\\Value\\Money:private] =&gt; 0.00
  [currency:Coinbase\\Wallet\\Value\\Money:private] =&gt; USD
  )
  [createdAt:Coinbase\\Wallet\\Resource\\Account:private] =&gt; DateTime Object (
  [date] =&gt; 2016-05-22 13:33:36.000000
  [timezone_type] =&gt; 2
  [timezone] =&gt; Z
  )
  [updatedAt:Coinbase\\Wallet\\Resource\\Account:private] =&gt; DateTime Object (
  [date] =&gt; 2016-05-22 13:33:36.000000
  [timezone_type] =&gt; 2
  [timezone] =&gt; Z
  )
  [id:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; c95fd701-cf2b-56f7-b438-9a2f0e61b21c
  [resource:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; account
  [resourcePath:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; /v2/accounts/c95fd701-cf2b-56f7-b438-9a2f0e61b21c
  [rawData:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; Array (
  [id] =&gt; c95fd701-cf2b-56f7-b438-9a2f0e61b21c
  [name] =&gt; iLy
  [primary] =&gt;
  [type] =&gt; wallet
  [currency] =&gt; BTC
  [balance] =&gt; Array (
  [amount] =&gt; 0.00000000
  [currency] =&gt; BTC
  )
  [native_balance] =&gt; Array (
  [amount] =&gt; 0.00
  [currency] =&gt; USD
  )
  [created_at] =&gt; 2016-05-22T13:33:36Z
  [updated_at] =&gt; 2016-05-22T13:33:36Z
  [resource] =&gt; account
  [resource_path] =&gt; /v2/accounts/c95fd701-cf2b-56f7-b438-9a2f0e61b21c
  )
  )
  [3] =&gt; Coinbase\\Wallet\\Resource\\Account Object (
  [name:Coinbase\\Wallet\\Resource\\Account:private] =&gt; BTC Wallet
  [primary:Coinbase\\Wallet\\Resource\\Account:private] =&gt; 1
  [type:Coinbase\\Wallet\\Resource\\Account:private] =&gt; wallet
  [currency:Coinbase\\Wallet\\Resource\\Account:private] =&gt; BTC
  [balance:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Coinbase\\Wallet\\Value\\Money Object (
  [amount:Coinbase\\Wallet\\Value\\Money:private] =&gt; 0.10000000
  [currency:Coinbase\\Wallet\\Value\\Money:private] =&gt; BTC
  )
  [nativeBalance:Coinbase\\Wallet\\Resource\\Account:private] =&gt; Coinbase\\Wallet\\Value\\Money Object (
  [amount:Coinbase\\Wallet\\Value\\Money:private] =&gt; 1000.00
  [currency:Coinbase\\Wallet\\Value\\Money:private] =&gt; USD
  )
  [createdAt:Coinbase\\Wallet\\Resource\\Account:private] =&gt; DateTime Object (
  [date] =&gt; 2016-05-21 02:41:13.000000
  [timezone_type] =&gt; 2
  [timezone] =&gt; Z
  )
  [updatedAt:Coinbase\\Wallet\\Resource\\Account:private] =&gt; DateTime Object (
  [date] =&gt; 2016-05-21 02:41:14.000000
  [timezone_type] =&gt; 2
  [timezone] =&gt; Z
  )
  [id:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; 0e0dac44-6900-59e9-8183-99b9459d1205
  [resource:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; account
  [resourcePath:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; /v2/accounts/0e0dac44-6900-59e9-8183-99b9459d1205
  [rawData:Coinbase\\Wallet\\Resource\\Resource:private] =&gt; Array (
  [id] =&gt; 0e0dac44-6900-59e9-8183-99b9459d1205
  [name] =&gt; BTC Wallet
  [primary] =&gt; 1
  [type] =&gt; wallet
  [currency] =&gt; BTC
  [balance] =&gt; Array (
  [amount] =&gt; 0.10000000
  [currency] =&gt; BTC
  )
  [native_balance] =&gt; Array (
  [amount] =&gt; 1000.00
  [currency] =&gt; USD
  )
  [created_at] =&gt; 2016-05-21T02:41:13Z
  [updated_at] =&gt; 2016-05-21T02:41:14Z
  [resource] =&gt; account
  [resource_path] =&gt; /v2/accounts/0e0dac44-6900-59e9-8183-99b9459d1205
  )
  )
  )
  )</code></pre>
  </div>
  </div>
  </p>