Better idea than triple nested switch?
Hi I've got some form for uploading files through php script, where user pick a one category, than second sub-category and then type of file.
I have to upload it on server into correct directory and path will looks like ..../category/sub-category/type/file.xxx --- and then I put whole absolute path to my database
By now I've got triple nested switch, is there any other way how to do it in better way?
Thanks a lot!
There is a pic of HTML code and PHP -- > http://oi59.tinypic.com/352qclx.jpg
Not sure at what point does the switch come in. However, can't you just do something like following in a single statement?
$complete_filepath = "..../$category/$sub_category/$type/$filename";
May be a multi-demension array will help you to solve it. like this:
$arr_dir_conf = array("dir_conf" => array("category1" => array("sub_category1" => array("type1" => "directory/category1/sub_category1/type1"), ... array("typen" => "directory/category1/sub_category1/typen") ), ... array("sub_categoryn" => ... ), ), ... );
Then you just use the array like this: