note 36669 added to function.include
| From: | srjosh at !nospam! dot maestrakara dot com | Date: | Sat, 18 Oct 2003 04:17:21 +0000 |
| Subject: | note 36669 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-58785@lists.php.net to get a copy of this message | ||
CORRECTION:
function new_address($dest){
//splits current directory into an array to be compared to target directory.
$current = explode ("/", $_SERVER["SCRIPT_NAME"]);
//splits target directory into an array to be compared to current directory.
$dest = explode ("/", $dest);
for ($x=0;$x<count($dest);$x++){
if ($dest[$x]==$current[$x] && count($current) > 2){
$toURL = $toURL . "../";
} elseif ($dest[$x]!=$current[$x] && $x == count($dest)-1) {
$toURL = $toURL . $dest[$x];
} elseif ($dest[$x]!=$current[$x]) {
$toURL = $toURL . $dest[$x] . "/";
}
}
return ($toURL);
}
Original code only worked in subdirectories. This works everywhere.
My first addition to the PHP dox, followed immediately by my first correction. typical.
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36669
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36669&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36669&report=yes
Search -- http://master.php.net/manage/user-notes.php