Mid-Atlantic Developer Conference - Call for Speakers


Please answer this simple SPAM challenge: min(six, one)?
(Example: nine)

The Note You're Voting On

andy dot gajetzki at gmail dot com
12 years ago
I wanted to be able to embed a variable in the path. This is useful when, for example, images are rendered on the fly and you would like them to have different urls.

Here is an illustration:


This would return an image with the text after "image.php/" contained in it.

I could not recall the name of this feature, so I made a work-around in PHP...

function getPathVariables() {
        $sPathPS = $_SERVER[PHP_SELF];
        $sPathFS = __FILE__;

        $aPathPS = array_reverse(explode("/", $sPathPS));
        $aPathFS = array_reverse(explode("/", $sPathFS));

        $aImageArgs = array();
        $x = 0;

        while ( $aPathPS[$x] != $aPathFS[$x] && $aPathPS[$x] != $aPathFS[0] ) {
                array_unshift($aImageArgs, $aPathPS[$x])        ;
        return $aImageArgs;


This function will return an array containing each "/" delimited portion of the path after the script name itself.

<< Back to user notes page

To Top