Multi dimension Array uitlezen

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Joni Fleischer
Moderator

Joni Fleischer

18/02/2016 13:11:47
Quote Anchor link
Hallo allemaal,

Ik ben echt slecht met Array's.
Zou iemand mij kunnen vertellen hoe ik onderstaande array het beste uitlees?

Heb momenteel:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
echo '<table>';
  foreach($response as $keys):
    if(!is_array($keys)):
      foreach($keys as $key => $value):
        echo '<tr>';
          echo '<td>'.$key.'</td>';
          echo '<td>'.$value.'</td>';
        echo '</tr>';
      endforeach;
    endif;

  endforeach;
echo '</table>';
?>


Array zelf is:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
SimpleXMLElement Object
(
    [Consignment] => SimpleXMLElement Object
        (
            [ConsignmentNumber] => 880618471
            [OriginDepotName] => Zwolle
            [CustomerReference] => RETURN 20160035
            [CollectionDate] => 4 Feb 2016
            [DeliveryTown] => ALMERE
            [DeliveryDate] => 5 Feb 2016
            [DeliveryTime] => 16:19
            [Signatory] => michel
            [SummaryCode] => Delivered
            [Cou-Id-Dest] => Netherlands
            [Cou-Id-Orig] => Netherlands
            [SearchType] => C
            [SearchKey] => 880618471
            [TOPaccountNo] => 245500
            [TOPaccountCouID] => Netherlands
            [SenderaccountNo] => 245500
            [SenderCouID] => Netherlands
            [StatusData] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT DELIVERED IN GOOD CONDITION.
                            [LocalEventDate] => 5 Feb 2016
                            [LocalEventTime] => 16:19
                            [Depot] => Amsterdam Depot
                        )

                    [1] => SimpleXMLElement Object
                        (
                            [Status] => OUT FOR DELIVERY.
                            [LocalEventDate] => 5 Feb 2016
                            [LocalEventTime] => 10:23
                            [Depot] => Amsterdam Depot
                        )

                    [2] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT RECEIVED AT TNT LOCATION
                            [LocalEventDate] => 5 Feb 2016
                            [LocalEventTime] => 04:42
                            [Depot] => Amsterdam Depot
                        )

                    [3] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT IN TRANSIT.
                            [LocalEventDate] => 4 Feb 2016
                            [LocalEventTime] => 22:08
                            [Depot] => Arnhem Hub
                        )

                    [4] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT RECEIVED AT TRANSIT POINT.
                            [LocalEventDate] => 4 Feb 2016
                            [LocalEventTime] => 21:53
                            [Depot] => Arnhem Hub
                        )

                    [5] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT RECEIVED AT TNT LOCATION
                            [LocalEventDate] => 4 Feb 2016
                            [LocalEventTime] => 21:44
                            [Depot] => Arnhem Hub
                        )

                    [6] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT IN TRANSIT.
                            [LocalEventDate] => 4 Feb 2016
                            [LocalEventTime] => 19:59
                            [Depot] => Zwolle
                        )

                    [7] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT IN TRANSIT.
                            [LocalEventDate] => 4 Feb 2016
                            [LocalEventTime] => 17:32
                            [Depot] => Zwolle
                        )

                    [8] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT RECEIVED AT ORIGIN DEPOT.
                            [LocalEventDate] => 4 Feb 2016
                            [LocalEventTime] => 17:31
                            [Depot] => Zwolle
                        )

                    [9] => SimpleXMLElement Object
                        (
                            [Status] => SHIPMENT COLLECTED FROM CUSTOMER
                            [LocalEventDate] => 4 Feb 2016
                            [LocalEventTime] => 13:54
                            [Depot] => Zwolle
                        )

                )

        )

)


Ik wil dus zodra hij bij StatusData aankomt, deze ook weer in keys en values uitspuugt.

Iemand enig idee?

Alvast bedankt!
Gewijzigd op 18/02/2016 13:13:47 door Joni Fleischer
 
PHP hulp

PHP hulp

05/06/2020 05:02:17
 
- SanThe -

- SanThe -

18/02/2016 13:14:20
Quote Anchor link
Dit gaat niet goed lijkt mij:

if(!is_array($keys)):
foreach($keys as $key => $value):

Als het GEEN array is ga jij het doorlopen.
 
Joni Fleischer
Moderator

Joni Fleischer

18/02/2016 13:16:52
Quote Anchor link
Heb if(is_array) weggehaald..

Maar moet er niet nog een foreach loop in??

Website: http://mijnpompen.nl/BETA/tnt/ECtracker.php

Toevoeging op 18/02/2016 13:17:41:

Wil dus ook dat hij bij statusdata niet 10 keer statusdata weergeeft, maar statusdata als aparte loop opnieuw uitspuugt.
 
- SanThe -

- SanThe -

18/02/2016 13:21:57
Quote Anchor link
Joni Fleischer op 18/02/2016 13:16:52:
Heb if(is_array) weggehaald..


Je moet dat niet weghalen, alleen de NOT (!).
 
Randy vsf

Randy vsf

18/02/2016 14:24:46
Quote Anchor link
Array zelf is:
SimpleXMLElement Object
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.