【问题标题】:how to get value from array in array in array?如何从数组中的数组中获取值?
【发布时间】:2011-08-16 10:14:08
【问题描述】:

我在print_r($_POST) 时得到这个数组,从下面的结果中我想得到skin 的值。

[skin] => 1.jpg

我该怎么做???

 Array
    (
        [form_key] => WceDMPJOQD17ZeSW
        [config_state] => Array
            (
                [themeoptions_general] => 1
            )

        [groups] => Array
            (
                [general] => Array
                    (
                        [fields] => Array
                            (
                                [themeoptions_images] => Array
                                    (
                                        [skin] => 1.jpg
                                    )

                                [themeoptions_customcss] => Array
                                    (
                                        [value] => color:#333;
                                    )

                            )

                )

        )

)

【问题讨论】:

  • $arr['groups']['general']['fields']['themeoptions_images']['skin']
  • btw $arr 在您的情况下可能需要替换为 $_POST... 还要查看您的 @ 以便您可以在前面添加它以避免丑陋的错误定义...thesmithfam.org/blog/2006/05/07/php-the-operator
  • 这与 Magento 无关,可能被称为一个太简单的问题:-s
  • 它与 magento dea Lucasmus 中的渲染器有关,有时太简单的事情会使生活变得地狱:)
  • @lucas 我同意,这对其他人没有帮助,因为它是基本且非常基础的脚本知识,此外,深度数组中的$_POST 并不是最佳实践。

标签: php magento magento-1.4 magento-1.5


【解决方案1】:
$_POST['groups']['general']['fields']['themeoptions_images']['skin']

这会给你皮肤的价值。

【讨论】:

    【解决方案2】:
    echo $_POST['groups']['general']['fields']['themeoptions_images']['skin']
    

    打印

    1.jpg
    

    【讨论】:

      猜你喜欢
      • 2019-05-14
      • 2018-08-09
      • 1970-01-01
      • 1970-01-01
      • 2019-03-25
      • 2022-11-17
      • 1970-01-01
      相关资源
      最近更新 更多