0

Apologies if this is a duplication of another answer, I have spent a considerable amount of time looking through this and other forums without finding an explanation that makes sense to my very small brain.

I have a multi-dimensional array that I need to parse through using PHP:

Array
(
    [dataSetOut] => Array
        (
            [diffgram] => Array
                (
                    [anonymous] => Array
                        (
                            [maindb_productionhistory] => Array
                                (
                                    [0] => Array
                                        (
                                            [z_internal_sequence] => 1
                                            [z_internal_groupid] => 0
                                            [z_internal_colorbg] => 15461355
                                            [z_internal_colorfg] => 0
                                            [maindb_productionhistory_operation] => 0402D04
                                            [maindb_productionhistory_date] => 2014-02-19T00:00:00+00:00
                                            [maindb_productionhistory_shift] => 1
                                            [maindb_productionhistory_transcode] => 33
                                            [maindb_productionhistory_qty] => 153
                                            [!diffgr:id] => maindb_productionhistory1
                                            [!msdata:rowOrder] => 0
                                        )

                                    [1] => Array
                                        (
                                            [z_internal_sequence] => 2
                                            [z_internal_groupid] => 0
                                            [z_internal_colorbg] => 16777215
                                            [z_internal_colorfg] => 0
                                            [maindb_productionhistory_operation] => 0402D04
                                            [maindb_productionhistory_date] => 2014-02-19T00:00:00+00:00
                                            [maindb_productionhistory_shift] => 1
                                            [maindb_productionhistory_transcode] => 34
                                            [maindb_productionhistory_qty] => 6
                                            [!diffgr:id] => maindb_productionhistory2
                                            [!msdata:rowOrder] => 1
                                        )
                                )
                        )
                )
        )
    [errorMessage] => 
)

I am looking to output a table like:

Operation | Date | Qty

0402D04 | 2014-02-19 | 153

0402D04 | 2014-02-19 | 6

1
  • I think your usage of the term "parse"is incorrect here. It sounds like you are just asking how to access the data in `$array['datasetOut']['diffgram']['anonymous']['maindb_productionhistory'], right? If that is that case, what is preventing you from simply access that array at that location? Commented Jul 31, 2014 at 14:05

1 Answer 1

1
<table>
<thead>
<tr>
<th>Operation</th>
<th>Date</th>
<th>Qty</th>
</tr>
</thead>
<tbody>
<?php
foreach($array['dataSetOut']['diffgram']['anonymous']['maindb_productionhistory'] as $val){
   echo "<tr>";
   echo "<td>".$val['maindb_productionhistory_operation']."</td>";
   echo "<td>".date('Y-m-d',strtotime($val['maindb_productionhistory_date']))."</td>";
   echo "<td>".$val['maindb_productionhistory_qty']."</td>";
   echo "</tr>";
 }
?>
</tbody>
</table>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Daan! <10 minutes not bad! :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.