Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 遍历多维数组_Php_Arrays_Loops_Multidimensional Array - Fatal编程技术网

Php 遍历多维数组

Php 遍历多维数组,php,arrays,loops,multidimensional-array,Php,Arrays,Loops,Multidimensional Array,我正在与Magento API交互,调用后: $result = $soap->call( $session_id, 'catalog_product.list' ); 我得到一个数组,里面充满了数组信息,我知道这一点,因为在对它执行print\u f之后,我得到了以下结果: Array( [0] => Array( [product_id] => 2 [sku] => 401HCS [name] => Paul Penders Hydrating Control

我正在与Magento API交互,调用后:

$result = $soap->call( $session_id, 'catalog_product.list' );
我得到一个数组,里面充满了数组信息,我知道这一点,因为在对它执行print\u f之后,我得到了以下结果:

Array( [0] => Array( [product_id] => 2 [sku] => 401HCS [name] => Paul Penders Hydrating Control Serum (20g) [set] => 4 [type] => simple [category_ids] => 

Array ( [0] => 4 [1] => 15 [2] => 43 ) )

[1] => Array ( [product_id] => 3 [sku] => 400ICT [name] => Paul Penders Intensive Clarifying Therapy (ICT) [set] => 4 [type] => simple [category_ids]

Array ( [0] => 4 [1] => 11 [2] => 43 ) ) 

[2] => Array ( [product_id] => 4 [sku] => 402CFE [name] => Paul Penders Herbal Citrus Fruit Exfoliant (60ml) [set] => 4 [type] => simple [category_ids] => 

它没有明显的缩进,我这样做是为了便于阅读,所以我的问题是如何遍历某种循环,以便进入每个数组并获得[product_id]和其他元素?提前谢谢

它被标记为“java”,但显然是php。您可以像这样遍历它:

foreach ($result as $id => $data) {
   foreach ($data as $key => $value) {
      switch ($key) {
         case 'product_id':
            // do things
            break;
         case 'sku':
            // do things
            break;
         // (...)

你的问题与android有什么关系?与android无关。删除标签吗?哎呀,最近做了很多android,我错了。