Monday 15 June 2015

php - Use foreach in an array -


IM is currently trying to generate a dynamic subnavigation. For this, I delete the database data and store some of it in an array. Now I want to do a foreach in this array. Okay as far as I know, this is not possible.

But maybe I am wrong I would like to know that this would be possible, and if so, how do I do it?

This is my code, which does not work because it returns a syntax error.

  $ this-> Subnav = array ('' test link ''> 'login.php', 'bad link) = & gt; array (' warning ', 10023,' check.php ')) , 'Benjeller' = & gt; Array ('Benuczar Suchen' = 'gt;' /mother/index.php?page=benutzer&subpage=serach_user ',' Benuczar Hinzuf ¼ Jane '=>' / Mummy / Index Php? Page = benutzer and subpage = Add_user ',' Rechtevergabe '=>' /mother/index.php?page=benutzer&subpage=user_rights'), 'logout' = & gt; Array ('Login' = & gt; '/mother/login.php', 'Logout' = & gt; '/mother/index.php?page=logout'), 'datenbank' = & gt; The array ((foreach ($ this-> System-> get_databases) as $ Db) {array ($ db-> name => $ db-> url}}) Deutschland '= & gt;' /mother/login.php ',' Polen '=>' / Mother / Index.php ',' Spanien '=>' /mother/index.php ',' Datenbanc Hinzuf ¼ Jane '=>' /mother/index.php?page=datenbank&subpage=add_databas e ')); }    

You can not have a foreach loop inside an array like this. Although you can do something like this

  foreach ($ this-> system-> get_databases () $ db) {$ this- & gt; Subnav ['datenbank'] [$ dB- & gt; Name] = $ db- & gt; Url; }    

No comments:

Post a Comment