php - Adding to a nested array -


i have issue trying add values 1 array that's nested under original array's name.

for example, script returns array:

<?php return array ( 'http' => array(      'get' => array(          '/' => function() {          },      ),      'post' => array(          '/' => function($username, $password) {          },      )  ),  'https' => array(      'get' => array(          '/account/(:num)' => function($number) {          }      ) ) 

then have class var of:

private $routes = array(     'http' => array(         'get'  => array(),         'post' => array()     ),     'https' => array(         'get'  => array(),         'post' => array()     ),     'filtrers' =>         'before' => array(),         'after' => array() ); 

what doing using glob read files, issue can't work out how loop though arrays first scrsipt , push them var.

var be:

 private $routes = array(     'http' => array(         'get'  => array(              'example' => array(                  '/' => function() {                    },              )         ),         'post' => array(              'example' => array(                  '/account/(:num)' => function($number) {                    },              )         )     ),     'https' => array(         'get'  => array(              'example' => array(                  '/' => function() {                    },              )         ),         'post' => array()     ),     'filtrers' =>         'before' => array(),         'after' => array() ); 

the why can think of using around 4 nested foreaches, or duplicating code each array set

assuming first array stored in $input can use this. have hard-coded 'example' based on expected output.

foreach ($input $protocol => $methods) {     foreach ($methods $method => $routearray) {         $routes[$protocol][$method]['example'] = $routearray;     } } 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -