View Full Version : Multi level categories
Hi,
I cannot seem to find any articles about multi level categories and sub categories in php.
I only know how to create a 1 level categories only. Does anyone know how or could point me into the right direction?
thanks in advance.
Sami
Categories of what?
A filesystem setup will work, as will a tree setup with a database, where you have a table of "folders," each of which except the root has exactly one parent referenced.
I meant like using mkdir() to make a dir and add subdir into it.
I think it is something like this:
Top Level
- Sub1
- Sub1_1
- Sub1_2
- Sub2
- Sub3
mkdir (http://www.php.net/mkdir)('dir/subdir');
I'm learning how to explain this.
Just say that I a top level category or directory and I wanted to create very very deep into that category.
Like this...
Top Level > x > xx> and etc... nn>vv
So how would you create that from a php script. thanks.
djr33
05-02-2007, 10:30 PM
I'm so confused about even the general idea of what you are doing.
you're making folders on the site, right?
So... mkdir('a/b/c/d/e/.../z/whatever'); ?
With PHP5, you can:
mkdir('x/xx/blah/nn/vv', 0777, true);However, in earlier versions you'd have to do it one at a time:
$pathname = 'x/xx/blah/nn/vv';
$dirs = explode('/', $pathname);
foreach($dirs as $i => $dir)
mkdir(implode('/', array_slice($dirs, 0, $i + 1)));
djr33
05-03-2007, 11:27 AM
Oh, I didn't think of that. I was just accessing the folder, forgetting that I was creating it as that function. How silly.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.