[Mapserver-users] listing field names of my $oShape->values; (Because it's Friday???)

Denis Lalonde denlalonde at yahoo.com
Fri Feb 27 15:34:57 EST 2004


--0-902877681-1077914097=:78758
Content-Type: text/plain; charset=us-ascii

Hello all,
I'm simply trying to get a list of the field names of a layer...
I'm using php & mapscipt 4 and accessing my MapInfo data (OGR)
Here's my code that's not working (I get "Undefined offset" error when accessing the array):
I have my results and my layer set; the result of my echo sizeof($flds) is 20 which is good. The item that I am querying does have data in all 20 fields.

                    $oRes = $oLayer->getResult($iRes);
                    $oShape = $oLayer->getShape(-1,$oRes->shapeindex);
                    
                    $flds=$oShape->values;
                    echo "numfields: ".sizeof($flds)."<br>";
                    for ($fieldcount=0; $fieldcount < sizeof($flds); $fieldcount++)
                        {
                           echo $flds[$fieldcount];
                        }
 
should that not spit me out my field names?
 
Thanks


---------------------------------
Do you Yahoo!?
Get better spam protection with Yahoo! Mail
--0-902877681-1077914097=:78758
Content-Type: text/html; charset=us-ascii

<DIV>Hello all,</DIV>
<DIV>I'm simply trying to get a list of the field names of a layer...</DIV>
<DIV>I'm using php &amp; mapscipt 4 and accessing my MapInfo data (OGR)</DIV>
<DIV>Here's my code that's not working (I get "Undefined offset" error when accessing the array):</DIV>
<DIV>I have my results and my layer set; the result of my echo sizeof($flds) is 20 which is good. The item that I am querying does have data in all 20 fields.</DIV>
<DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $oRes = $oLayer-&gt;getResult($iRes);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $oShape = $oLayer-&gt;getShape(-1,$oRes-&gt;shapeindex);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $flds=$oShape-&gt;values;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo "numfields: ".sizeof($flds)."&lt;br&gt;";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ($fieldcount=0; $fieldcount &lt; sizeof($flds);
 $fieldcount++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $flds[$fieldcount];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>should that not spit me out my field names?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks</DIV><p><hr SIZE=1>
Do you Yahoo!?<br>
Get better spam protection with <a href="http://us.rd.yahoo.com/mailtag_us/*http://antispam.yahoo.com/tools">Yahoo! Mail</a>
--0-902877681-1077914097=:78758--



More information about the mapserver-users mailing list