Jump to content

T-Bird

Members
  • Posts

    53
  • Joined

  • Last visited

    Never

Everything posted by T-Bird

  1. A friend and I had built a template system for one of our sites not long ago. It's actually not all that difficult. None of the pages you navigate to (I.E. domain.com/help.php) should have any HTML in them. Instead all HTML and CSS should be set in external files broken into modular blocks. So you might have header.htm, navbar.htm, body.htm, footer.htm. Your main files like help.php will simply use the include() function to attach the html files where necessary. Since things like your header wont be changing between pages on the site this lets you edit one HTML file and make a global change to your site.
  2. I'm also open to restructuring my directory tree if that would make it easier. Regardless, I need to navigate an N-dimensional array using a string or other input. If it helps this is the last thing I tried: if(isset($_GET['dir'])) { //open/close directories as necessary $toOpen = explode(":",$_GET['dir']); $depth = count($toOpen)-1; $arr = &$_SESSION['list']; foreach($toOpen as $key => $v) { if(array_key_exists($v,$_SESSION['list'])) { if($key < $depth) { $arr = $arr[$v]['size']; } else { $arr[$v]['open'] = (int) !$arr[$v]['open']; } } } } The problem with this being that I've lost all directory data above the level of the directory I just opened since it overwrites my SESSION variable.
  3. I am building a directory tree via array. I need to find a way to use a GET variable to navigate the tree. Here's an example: My array would be laid out as such $list = array(2) { [0] => array(2) { [‘name’] => Directory 1 [‘info’] => array(3) { [0] => array(2) { [‘name’] => File 1.a [‘info’] => foo } [1] => array(2) { [‘name’] => File 1.b [‘info’] => foo } [2] => array(2) { [‘name’] => File 1.c [‘info’] => foo } } } [1] => array(2) { [‘name’] => File 2 [‘info’] => foo } } Each directory holds one array per file. Should that file be a directory itself it holds another array for those sub directories. This can be an arbitrary depth. Now, I'm trying to take a GET variable (probably a string layed out as "3:0:1:...", but I'm up for alternative methods) that will tell the code how to navigate into the array and find the desired file. My thinking was that I would list which array index to go into so in the above string it would go to index 3, then in the array stored in that info index go to index 0 and then index 1, so-on-and-so-forth. My question: Short of an eval() function - which I don't want to use until it's my last choice since the data is coming off a user input - is there a way to tell PHP how far to navigate into an array that may be an arbitrary size in any given dimension? One last wrench in the works, I need the list to maintain state; it's in a session variable, so the process can't be destructive. Thanks in advance for the help
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.