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
)
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|