<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Parsing $_SERVER[&#039;PATH_INFO&#039;]</title>
	<atom:link href="http://blog.affien.com/archives/2004/12/12/parsing-_serverpath_info/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.affien.com/archives/2004/12/12/parsing-_serverpath_info/</link>
	<description>A few thoughts</description>
	<lastBuildDate>Tue, 22 Nov 2011 21:50:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ben Atkin</title>
		<link>http://blog.affien.com/archives/2004/12/12/parsing-_serverpath_info/comment-page-1/#comment-178780</link>
		<dc:creator>Ben Atkin</dc:creator>
		<pubDate>Tue, 12 Jul 2011 17:30:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.w-nz.com/archives/2004/12/12/parsing-_serverpath_info/#comment-178780</guid>
		<description>I was using Ruby but I was glad to find your article. It really shouldn&#039;t be that hard to find what path_info means on Google. *sigh*

Thank you for your concise article.</description>
		<content:encoded><![CDATA[<p>I was using Ruby but I was glad to find your article. It really shouldn&#8217;t be that hard to find what path_info means on Google. *sigh*</p>
<p>Thank you for your concise article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gus gando</title>
		<link>http://blog.affien.com/archives/2004/12/12/parsing-_serverpath_info/comment-page-1/#comment-178698</link>
		<dc:creator>gus gando</dc:creator>
		<pubDate>Sat, 02 Oct 2010 21:38:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.w-nz.com/archives/2004/12/12/parsing-_serverpath_info/#comment-178698</guid>
		<description>correction..
btw,
if (!isset($pathbits[1]) &#124;&#124; $pathbits[1] == &quot;&quot;){
	$page = &quot;default&quot;
}else{

missing semicolon - should read
	$page = &quot;default&quot;;</description>
		<content:encoded><![CDATA[<p>correction..<br />
btw,<br />
if (!isset($pathbits[1]) || $pathbits[1] == &#8220;&#8221;){<br />
	$page = &#8220;default&#8221;<br />
}else{</p>
<p>missing semicolon &#8211; should read<br />
	$page = &#8220;default&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cancuengt</title>
		<link>http://blog.affien.com/archives/2004/12/12/parsing-_serverpath_info/comment-page-1/#comment-178650</link>
		<dc:creator>cancuengt</dc:creator>
		<pubDate>Mon, 05 Apr 2010 16:17:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.w-nz.com/archives/2004/12/12/parsing-_serverpath_info/#comment-178650</guid>
		<description></description>
		<content:encoded><![CDATA[<p>You must provide $default with an array containing the values you want to extract as key and the default value for each.</p>
<p>By example, to extract the page topic, book and page and the number with this path: &#8216;/support/bash/8&#8242; you must pass $default with<br />
array(&#8216;topic&#8217; =&gt; &#8216;defaulttopic&#8217;,'book&#8217;=&gt;&#8217;defaultbook&#8217;,'page&#8217;=&gt;1)</p>
<p>The following elementh in the path will be returner in a name = value pairs as follows: (/support/bash/8/link/title1)</p>
<p>array(<br />
  &#8216;topic&#8217; =&gt; &#8216;support&#8217;,<br />
  &#8216;book&#8217; =&gt; &#8216;bash&#8217;,<br />
  &#8216;page&#8217; =&gt; 8,<br />
  &#8216;link&#8217;   =&gt; &#8216;title1&#8242;,<br />
)</p>
<p>Enjoy. </p>
<p>function router($default)<br />
{<br />
    $keys    = array_keys($default);<br />
    $pos     = 0;<br />
    $res     = array();<br />
    $name    = isset($keys[$pos])?$keys[$pos]:&#8221;;<br />
    foreach(explode(&#8216;/&#8217;,isset($_SERVER['PATH_INFO'])?$_SERVER['PATH_INFO']:&#8221;) as $value){<br />
        if($value != &#8221;){<br />
            if($name == &#8221;){<br />
                $name = $value;<br />
            }else{<br />
                $res[$name] = $value;<br />
                $pos++;<br />
                $name = isset($keys[$pos])?$keys[$pos]:&#8221;;<br />
            }<br />
        }<br />
    }<br />
    if($name != &#8221;){ // Si se pasó un parámetro pero no su valor<br />
        $res[$name] = &#8221;;<br />
    }<br />
    foreach($default as $key =&gt; $value){ // Valores default, por si no existen<br />
        if(!isset($res[$key]) || ($res[$key] == &#8221;)){<br />
            $res[$key] = $value;<br />
        }<br />
    }<br />
    return $res;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.affien.com/archives/2004/12/12/parsing-_serverpath_info/comment-page-1/#comment-170483</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Tue, 13 May 2008 10:01:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.w-nz.com/archives/2004/12/12/parsing-_serverpath_info/#comment-170483</guid>
		<description>Useful!</description>
		<content:encoded><![CDATA[<p>Useful!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

