<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >gopher_parsedir</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Net_Gopher" HREF="ref.net-gopher.html"><LINK REL="PREVIOUS" TITLE="Net_Gopher" HREF="ref.net-gopher.html"><LINK REL="NEXT" TITLE="Haru PDF Functions" HREF="ref.haru.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="ref.net-gopher.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="ref.haru.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.gopher-parsedir" ></A >gopher_parsedir</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN61931" ></A ><P > (PECL)</P >gopher_parsedir -- Translate a gopher formatted directory entry into an associative array.</DIV ><DIV CLASS="refsect1" ><A NAME="AEN61934" ></A ><H2 >Descrição</H2 >array <B CLASS="methodname" >gopher_parsedir</B > ( string dirent )<BR ></BR ><P > <B CLASS="function" >gopher_parsedir()</B > parses a gopher formatted directory entry into an associative array. </P ><P > While gopher returns <TT CLASS="literal" >text/plain</TT > documents for actual document requests. A request to a directory (such as /) will return specially encoded series of lines with each line being one directory entry or information line. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN61946" ></A ><H2 >Parâmetros</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >dirent</CODE ></DT ><DD ><P > The directory entry. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN61955" ></A ><H2 >Valores de retornado</H2 ><P > Returns an associative array whose components are: <P ></P ><UL ><LI ><P > <CODE CLASS="structfield" >type</CODE > - One of the <TT CLASS="literal" >GOPHER_XXX</TT > constants. </P ></LI ><LI ><P > <CODE CLASS="structfield" >title</CODE > - The name of the resource. </P ></LI ><LI ><P > <CODE CLASS="structfield" >path</CODE > - The path of the resource. </P ></LI ><LI ><P > <CODE CLASS="structfield" >host</CODE > - The domain name of the host that has this document (or directory). </P ></LI ><LI ><P > <CODE CLASS="structfield" >port</CODE > - The port at which to connect on <CODE CLASS="structfield" >host</CODE >. </P ></LI ></UL > </P ><P > Upon failure, the additional <CODE CLASS="structfield" >data</CODE > entry of the returned array will hold the parsed line. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN61978" ></A ><H2 >Exemplos</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN61981" ></A ><P ><B >Exemplo 1. Hypothetical output from <TT CLASS="literal" >gopher://gopher.example.com/</TT ></B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >0All about my gopher site. /allabout.txt gopher.example.com 70 9A picture of my cat. /pics/cat.png gopher.example.com 70 1A collection of my writings. /stories gopher.example.com 70 hThe HTTP version of this site. URL:http://www.example.com gopher.example.com 70 1Mirror of this site in Spain. / gopher.ejemplo.co.es 70 iWelcome to my gopher site. error.host 1 iPlease select one of the options above error.host 1 iSend complaints to /dev/null error.host 1 iLong live gopher! error.host 1</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > In the example above, the root directory at gopher.example.com knows about one <TT CLASS="literal" >DOCUMENT</TT > identified by <TT CLASS="literal" >0</TT > located at <TT CLASS="literal" >gopher://gopher.example.com:70/allabout.txt</TT >. It also knows about two other directory (which have their own listing files) at <TT CLASS="literal" >gopher://gopher.exmaple.com:70/stories</TT > and at <TT CLASS="literal" >gopher://gopher.ejemplo.co.es:70/</TT >. In addition there is a binary file, a link to an HTTP url, and several informative lines. </P ><P > By passing each line of the directory listing into <B CLASS="function" >gopher_parsedir()</B >, an associative array is formed containing a parsed out version of the data. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN61994" ></A ><P ><B >Exemplo 2. Using <B CLASS="function" >gopher_parsedir()</B ></B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />$directory </font><font color="#007700">= </font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#DD0000">"gopher://gopher.example.com"</font><font color="#007700">);<br /><br />foreach(</font><font color="#0000BB">$directory </font><font color="#007700">as </font><font color="#0000BB">$dirent</font><font color="#007700">) {<br /> </font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">gopher_parsedir</font><font color="#007700">(</font><font color="#0000BB">$dirent</font><font color="#007700">));<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P >O exemplo acima irá imprimir:</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >Array ( [type] => 0 [title] => All about my gopher site. [path] => /allabout.txt [host] => gopher.example.com [port] => 70 ) Array ( [type] => 9 [title] => A picture of my cat. [path] => /pics/cat.png [host] => gopher.example.com [port] => 70 ) Array ( [type] => 1 [title] => A collection of my writings. [path] => /stories [host] => gopher.example.com [port] => 70 ) Array ( [type] => 254 [title] => The HTTP version of this site. [path] => URL:http://www.example.com [host] => gopher.example.com [port] => 70 ) Array ( [type] => 1 [title] => Mirror of this site in Spain. [path] => / [host] => gopher.ejemplo.co.es [port] => 70 ) Array ( [type] => 255 [title] => Welcome to my gopher site. [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Please select one of the options above. [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Send complaints to /dev/null [path] => [host] => error.host [port] => 1 ) Array ( [type] => 255 [title] => Long live gopher! [path] => [host] => error.host [port] => 1 )</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="ref.net-gopher.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="ref.haru.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Net_Gopher</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.net-gopher.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Haru PDF Functions</TD ></TR ></TABLE ></DIV ></BODY ></HTML >