PHP: simplify with algorithm? -


This is a piece of PHP code, I think that is not "too much", I'm sure that I'm trying to find and algorithm it for or something that will work for it, But I can not understand it, please help me.

Here is the code:

 if (isset ($ 4)) {ifet ($ navi [$ one] [$ 2] [$ three] [$ 4])) "/ Content /" $ one "/" $ two "/" $ three "/". $ 4 ".php"; Second echo "error"; } And if (isset ($ three)) echo "/ content" "$ one" / "$ 2" / "$ three") .php "; Second echo "error"; } And if (isset ($ 2)) {if (isset ($ navi [$ one] [$ 2]) echo "/ content /" $ one "/" $ two ".php"; Second echo "error"; } And if (isset ($ one)) {if (isset ($ navi [$ one])) "/ content /" $ "$ .php"; Second echo "error"; } And {echo "error"; }  

Thanks!

updated, tested:

  $ parts = array ( $ One, $ two, $ three, $ 4); $ Reverse = array_reverse ($ parts); Function getPath ($ ret $$) {global $ parts; Foreign currency (range (0, $ n) $ i) as {$ ret = $ ret [$ parts [$ i]]; } Return $ ret; } $ Error = false; $ I) {if (! $$ [I $] reversed) in foreign currency (category (0, count ($ reverse)) {currency ($ reversed [$ i]); to continue; } If (GetPath ($ navi, count ($ parts) - $ i - 1)) {$ error = true; break; }} If ($ error) {echo "error!"; } And {echo "/ content /" implode ("/", array_reverse ($ reverse)). ".php"; }  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -