{"id":3398,"date":"2014-06-24T21:54:53","date_gmt":"2014-06-24T21:54:53","guid":{"rendered":"http:\/\/webninjataylor.com\/library\/?p=3398"},"modified":"2014-06-24T21:54:53","modified_gmt":"2014-06-24T21:54:53","slug":"php-arrays","status":"publish","type":"post","link":"https:\/\/webninjataylor.com\/library\/php-arrays\/","title":{"rendered":"PHP Arrays"},"content":{"rendered":"<pre>&lt;?php\r\n    \/\/Associative multidimensional array with named keys, called in reverse order to avoid returning NULL\r\n    $menuTests = array(\r\n        'ALMA' =&gt; '\/index.php\/about\/facilities\/alma',\r\n        'EVLA' =&gt; '\/index.php\/about\/facilities\/vlaevla',\r\n        'SKA' =&gt; '\/index.php\/about\/facilities\/ska',\r\n    );\r\n    $menu = array(\r\n        'Home' =&gt; '\/index.php',\r\n        'Tests' =&gt; array('\/cosmicradio\/test.php',$menuTests),\r\n        'Cosmic Radio' =&gt; '\/cosmicradio\/index.php'\r\n    );\r\n\r\n    echo \"&lt;pre&gt;\";\r\n        var_dump($menu);\r\n    echo \"&lt;\/pre&gt;\";\r\n    echo $menu['Tests'][1];\r\n    foreach($menu as $itemPrimary =&gt; $urlPrimary){\r\n        echo \"$itemPrimary: $urlPrimary &lt;br \/&gt;\";\r\n        foreach($menuTests as $itemSecondary =&gt; $urlSecondary){\r\n            echo \"&lt;b&gt;$itemSecondary - $urlSecondary ... &lt;\/b&gt;&lt;br \/&gt;\";\r\n        }\r\n    }\r\n\r\n?&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php \/\/Associative multidimensional array with named keys, called in reverse order to avoid returning NULL $menuTests = array( &#8216;ALMA&#8217; =&gt; &#8216;\/index.php\/about\/facilities\/alma&#8217;, &#8216;EVLA&#8217; =&gt; &#8216;\/index.php\/about\/facilities\/vlaevla&#8217;, &#8216;SKA&#8217; =&gt; &#8216;\/index.php\/about\/facilities\/ska&#8217;, ); $menu = array( &#8216;Home&#8217; =&gt; &#8216;\/index.php&#8217;, &#8216;Tests&#8217; =&gt; array(&#8216;\/cosmicradio\/test.php&#8217;,$menuTests), &#8216;Cosmic Radio&#8217; =&gt; &#8216;\/cosmicradio\/index.php&#8217; ); echo &#8220;&lt;pre&gt;&#8221;; var_dump($menu); echo &#8220;&lt;\/pre&gt;&#8221;; echo $menu[&#8216;Tests&#8217;][1]; foreach($menu as $itemPrimary =&gt; $urlPrimary){ echo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[144],"tags":[6],"class_list":["post-3398","post","type-post","status-publish","format-standard","hentry","category-web-shots","tag-php"],"_links":{"self":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/3398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/comments?post=3398"}],"version-history":[{"count":1,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/3398\/revisions"}],"predecessor-version":[{"id":3399,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/3398\/revisions\/3399"}],"wp:attachment":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/media?parent=3398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/categories?post=3398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/tags?post=3398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}