access element in nested array PHP - array to string conversion error -


i need have array structured so

array  (     [id] =>      [name] =>      [description] =>      [table_id] =>      [records] => array         (             [0] => array                 (                     [id] =>                      [table_id] =>                      [created] => 2016-01-15t09:19:36-0700                     [updated] =>                      [created_by] =>                      [updated_by] =>                      [fields] => array                         (                             [created] =>                              [delivery date] =>                              [total price including shipping] =>                             [enquiry status] =>                              [equipment booked 1] =>                             [equipment booked 2] =>                              [equipment booked 3] =>                              [equipment booked 4] =>                              [equipment booked 5] =>                             [equipment booked 6] =>                             [surname] =>                          )                  )          )      [record_count] => 1 ) 

i need extract [created] field last element of nested array in [records]. i've tried doing following

$target_elems = $target.['record_count']; //print_r($target_elems);  //echo $target_elems; //echo $target.['records'].[$target_elems].['created']; echo '<pre>'; print_r($target); echo '<pre/>'; 

bur array string conversion error (commented lines have been tested obviously).

the generated output is

arrayarrayarrayarray 

as said:- i need extract [created] field last element of nested array in [records].

first count number of records in records sub-array , data:-

<?php   $count = count($target['records']); // count number of record in records sub-array   echo $target['records'][$count-1]['created']; // last created records array ?> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -