PHP get value inside nested array/object -
I am trying to return the value of typeName key inside this object (xml)
[geometricProperty] = & gt; Array ([0] = & gt; Simple XML Object ([@attributes] = & gt; Array ([TypeName] = & gt; LocalAjacao // & lt; - - - This is my requirement.) [Point] = & Simple Accliment Object ([@attributes] = & gt; array ([ID] => gt; swrefVgetZredeVcollX757678785 [srs] => gtc: gtc: suffix = [coordinate] => 38871,739716)) [1] = & Simple expression object ([@attributes] = & gt; array ([typename] = & gt; limited) [polygon] => simple assemment object ([@attributes] => array ([ID] =) & Gt; SwrefVgeometryV08945038 [srs] => Utm_23_cm) [externalboundIs] => simple A Simulation object ([LinearRing] = & gt; Simple assemble object ([coordinates] => 318950,739 9 8585 3198139650 3182673990 31695679750))) ...
I have tried the following but this return of
echo " This object is". (Count ($ n-> Feature- & Gt; Geometric Property). "Item. & Lt; / p & gt;"; $ c = 0; Forex ($ n-> Feature-> Geometric Property as $) {$ c + +; Echo "& lt; p & gt; $ c)". (Gettype ($ k)). "& Lt; / p & gt;"; $ O) {echo "<<
{$ o} ["type name"]); $ Tipo = $ k- & gt; {$ O} ["TypeName"]; break; Case "point": $ value = $ k-> {$ O} - & gt; Coordinates; break; Case "Polygon": $ value = $ k-> {$ O} - & gt; Outer boundary IS-> LinearRing-> Coordinates; break; The case "Line ...": Break; }} Echo "& lt; p & gt; TIPO: $ tipo
VALOR: $ value
OUTPUT:
This object has 3 items 1) Object @ Votibles tap point TOPO: VOLOR: 31869871 739796106 2) Object @ Ventibates NewTel Polygon TOPO: Search and found and can not guess what I'm doing wrong.
You can use to get an array of properties. Then you will just loop them and display them or use implode or something else ... You want that depending on the output.
Comments
Post a Comment