note 61886 deleted from reserved.variables by philip
| From: | philip@php.net | Date: | Wed, 21 Feb 2007 15:58:21 +0000 |
| Subject: | note 61886 deleted from reserved.variables by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123642@lists.php.net to get a copy of this message | ||
Note Submitter: ticklemeozmo at gmail dot com
----
Using a combination of magic and a few examples from below (thank you to those below), the following
two functions should provide the script with a list (in order) of what is after the script.
printvars.php:
<?php
function array_compress($array) {
$aReturn = array();
foreach ($array as $value)
if (strlen($value) > 0) { $aReturn[] = $value; }
return $aReturn;
}
function getPathVariables() {
$sPathPS = $_SERVER[PHP_SELF];
$sPathFS = __FILE__;
$aPathPS = array_reverse(explode("/", $sPathPS));
$aPathFS = array_reverse(explode("/", $sPathFS));
$aReturn = array();
$x = 0;
while ( $aPathPS[$x] != $aPathFS[$x] && $aPathPS[$x] != $aPathFS[0] ) {
array_unshift($aReturn, $aPathPS[$x]) ;
$x++;
}
return $aReturn;
}
print_r(array_compress(getPathVariables()));
?>
----
Calling: http://www.website.com/temp/printvars.php/or/whatever/something.jpg
returns:
Array (
[0] => or
[1] => whatever
[2] => something.jpg
)