Thanks in advance for the help that will be received!
I used to use a code I made when I first started, due to not being able to find a snippet that does what I want. (Maybe to not knowing the terminology) I’m sure there’s a more simple way, which is why I’m asking advice.
/EDIT/
The pages that will use this template are temporarily hosted in a subdirectory of another website, and using “/” to start at the root of the page isn’t an option I want to go with, due to wanting to effortlessly drop the website on a different hosting server and add a domain name to the pages so the path from root (ex. “/temp-dir/site/images/image.jpg”) will need updated, whereas, using a previous directory (ex. “../../../images/image.jpg”) will work from existing site and new location upon move.
/endEDIT/
What I am trying to achieve is applying the proper amount of “../” before the file names in a header template using a method like:
<link href="<?php if(isset($pDepth)){ echo $prev; }?>style.css" />
Where $prev will equal previous directory code ranging from “../” to “../../../../” depending on the variable $pDepth on each web page. For example:
if($pDepth == 3){the output of $prev will equal "../../../"}
I seen where the output can change using ++, but you can’t add strings can you? I’m thinking something like:
if($pDepth == 4){
$i = 0;
while($i != $pDepth){
// help needed here
// add "../" until $prev = "../../../../"
}
}
I’m still learning to write code, and would appreciate any help. Thanks Again!
1 Answer