Tuesday, 15 January 2013

PHP Array multiple keys -


Here's what I want to do:

   

I need to parse multi-dimensional arrays independently, so I can use it on any multi-dimensional array.

"post-text" itemprop = "text">

Still guessing what you are trying to achieve

  $ this- & Gt; MyArray = array ("key1" = & gt; array ("key2" = & gt; array (1,2,3)); Protected function mdparser () {$ result = $ this- & gt; MyArray; For ($ i = 0; $ i & lt; func_num_args (); $ i ++) {$ result = $ result [func_get_arg ($ i)]; } Return result; } $ Result = it- & gt; Mdparser ('key1', 'key2', 1); PHP> = 5.6 allows variadics to be simplified:  
  protected function mdparser (... $ args) {$ result = $ This- & gt; MyArray; Foreign Currency ($ AGR $ ARG) {$ Result = $ Result [$ AG]; } Return result; }  

No comments:

Post a Comment