The following code is required: $ paramsArray ([tab1] Array ([server] Array ([0] 137 [1] 122) to generate the following Array: $ paramsArray ([tab1] [server] [0] 137, [tab1] [server] [1] 122); note that, is to integrate the subscript in the multi-dimensional array into a unified index
The following code is required: $ params = Array ([tab1] = Array ([server] = Array ([0] = 137 [1] = 122); generates the following Array: $ params = Array ([tab1] [server] [0] = 137, [tab1] [server] [1] = 122); note that, is to integrate the subscript in the multi-dimensional array into a unified index
The following code is required:
$ Params =
Array
(
[Tab1] => Array
(
[Server] => Array
(
[0] = & gt; 137
[1] => 122.
)
)
);
Generate the following array:
$ Params =
Array (
'[Tab1] [server] [0]' = 137,
'[Tab1] [server] [1]' = 122
);
Note that the subscript in the multi-dimensional array is integrated into a unified index.
I wrote a test code as follows to see if you have any better suggestions and ideas: EaglePHP
Source code and demo:Source code source demonstration Source
$params = array('tab1'=>array('server1'=>array(137, 122), 'server2'=>array(100,200)),'tab2'=>array('server3'=>array(400, 500), 'server4'=>array(600, 700), 'aaa'=>array('bbb'=>array(1,2,3))),'name' => 'dimain','abc' => array(4,5,6=>array('apple', 'lizi')) ); function test(&$params, &$tmpKeyArr, &$data){$i = 0;foreach ($params as $k=>&$v){$i++;if(is_array($v)) {$tmpKeyArr[] = '['.$k.']';test($v, $tmpKeyArr, $data);}else{$data[implode($tmpKeyArr, '').'['.$k.']'] = $v;}if(count($params) == $i) array_pop($tmpKeyArr);}}$tmpKeyArr = array();$data = array();test($params, $tmpKeyArr, $data);echo '';print_r($data);print_r($params);echo '
';