Answers.Body: <p>In the example you have given the way you would is </p>
  
  <p><code>$arrayvariable[2][0][value 1]</code> etc etc.</p>
  
  <p>You can see an example here for usage from CiviCRM API v3 <a href="https://docs.civicrm.org/dev/en/latest/api/options/#sequential" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/api/options/#sequential</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-09T22:51:17.800Z
Answers.LastActivityDate: 2017-09-09T22:51:17.800Z
Answers.UserDisplayName: Seamus Lee
Answers.Body: <p>I solved this problem by using a different CiviCRM API3 call so that I did not need to extract a value from an array. Instead in the API Explorer I selected the entity 'contact' and action 'getvalue'. I then selected the field that I wanted and that returned a single value which I was able to use without the need to use any array processing.
  In essence I walked around the issue.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-12T23:13:59.183Z
Answers.LastActivityDate: 2017-09-12T23:13:59.183Z
Answers.UserDisplayName: Martin Fuggle
Body: <p>I am trying to extract a custom field from a contact record. The API returns an array of the following form:</p>
  
  <pre><code>Array (
      [0] =&gt; 0
      [1] =&gt; 3
      [2] =&gt; array (
          [0] =&gt; array (
              [value 1] =&gt; 123
              [value 2] =&gt; 456
              [value 3] =&gt; 789
  )))
  </code></pre>
  
  <p>Using php how can I extract value 1, 2 or 3?</p>
  
  <p><strong>Later information</strong></p>
  
  <p>This is the actual array</p>
  
  <pre><code>Array (
  [0] =&gt; 0
  [1] =&gt; 3
  [2] =&gt; 1
  [3] =&gt; 2911
  [4] =&gt; Array (
      [0] =&gt; Array (
          [contact_id] =&gt; 2911
          [civicrm_value_aru_data_1_id] =&gt; 2586
          [custom_64] =&gt; 2014848
          [id] =&gt; 2911
  </code></pre>
  
  <p>)))</p>
  
  <p>and I want to extract the value of custom_64. I am using:</p>
  
  <pre><code>$rugby_id = $arrayvariable[4][0][custom_64];
  </code></pre>
  
  <p>which returns nothing and I can't see where I am going wrong.</p>
  
  <p><strong>Even later information</strong></p>
  
  <p>I am still struggling with this issue. In an attempt to simplify things I have changed the CiviCRM API call to 'getsingle' and stored the result as follows:</p>
  
  <pre><code>$results = print_r($result, true);
  echo $results;
  </code></pre>
  
  <p>which leads to the following:</p>
  
  <pre><code>Array (
  [contact_id] =&gt; 2911 
  [civicrm_value_aru_data_1_id] =&gt; 2586 
  [custom_64] =&gt; 2014848 
  [id] =&gt; 2911 
  ) 
  </code></pre>
  
  <p>If I now try to extract the value of custom_64 using:</p>
  
  <pre><code>$rugby_id = $results['custom_64'];
  </code></pre>
  
  <p>The value returned is 'A'. I have researched this to death but have not found the cause of the problem.</p>
  
Tags: <api><php>
Title: How to extract field from an array returned from an API3 call
ThreadText: # How to extract field from an array returned from an API3 call
  
  (Asked by: username_0 on 2017-09-09)
  
  I am trying to extract a custom field from a contact record. The API returns an array of the following form:
  
  ```
  Array (
      [0] => 0
      [1] => 3
      [2] => array (
          [0] => array (
              [value 1] => 123
              [value 2] => 456
              [value 3] => 789
  )))
  
  ```
  
  Using php how can I extract value 1, 2 or 3?
  
  **Later information**
  
  This is the actual array
  
  ```
  Array (
  [0] => 0
  [1] => 3
  [2] => 1
  [3] => 2911
  [4] => Array (
      [0] => Array (
          [contact_id] => 2911
          [civicrm_value_aru_data_1_id] => 2586
          [custom_64] => 2014848
          [id] => 2911
  
  ```
  
  )))
  
  and I want to extract the value of custom\_64. I am using:
  
  ```
  $rugby_id = $arrayvariable[4][0][custom_64];
  
  ```
  
  which returns nothing and I can't see where I am going wrong.
  
  **Even later information**
  
  I am still struggling with this issue. In an attempt to simplify things I have changed the CiviCRM API call to 'getsingle' and stored the result as follows:
  
  ```
  $results = print_r($result, true);
  echo $results;
  
  ```
  
  which leads to the following:
  
  ```
  Array (
  [contact_id] => 2911 
  [civicrm_value_aru_data_1_id] => 2586 
  [custom_64] => 2014848 
  [id] => 2911 
  ) 
  
  ```
  
  If I now try to extract the value of custom\_64 using:
  
  ```
  $rugby_id = $results['custom_64'];
  
  ```
  
  The value returned is 'A'. I have researched this to death but have not found the cause of the problem.
  
  **Tags:** api, php
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-09-09. Score: 1
  
  In the example you have given the way you would is
  
  `$arrayvariable[2][0][value 1]` etc etc.
  
  You can see an example here for usage from CiviCRM API v3 <https://docs.civicrm.org/dev/en/latest/api/options/#sequential>
  
  
  ---
  
  ### Answer by username_0 on 2017-09-12. Score: 0
  
  I solved this problem by using a different CiviCRM API3 call so that I did not need to extract a value from an array. Instead in the API Explorer I selected the entity 'contact' and action 'getvalue'. I then selected the field that I wanted and that returned a single value which I was able to use without the need to use any array processing.
  In essence I walked around the issue.
  
  
  ---
  
  