Php 保存以数组形式存储的数组内容';s内部阵列

Php 保存以数组形式存储的数组内容';s内部阵列,php,Php,我有这个数组。我只想将此数组([choices])中一个的内容提取到一个新数组中。我如何用php实现它 Array ( [0] => Array ( [key] => field_54df3275b708a [label] => Idioma [name] => idioma [type] => select [ins

我有这个数组。我只想将此数组([choices])中一个的内容提取到一个新数组中。我如何用php实现它

   Array
(
    [0] => Array
        (
            [key] => field_54df3275b708a
            [label] => Idioma
            [name] => idioma
            [type] => select
            [instructions] => 
            [required] => 0
            [choices] => Array
                (
                    [Catalan] => Catalan
                    [Castellano] => Castellano
                    [Ingles] => Ingles
                )

            [default_value] => 
            [allow_null] => 0
            [multiple] => 0
            [conditional_logic] => Array
                (
                    [status] => 0
                    [rules] => Array
                        (
                            [0] => Array
                                (
                                    [field] => null
                                    [operator] => ==
                                    [value] => 
                                )

                        )

                    [allorany] => all
                )

            [order_no] => 0
        )

)
我尝试了以下代码(我认为这是一个糟糕的代码):

foreach($k=>v的数组){
if(is_数组($v)){
foreach($v为$l=>$w){
如果($w){
foreach($w为$s=>t){
$idiomas[]=$t.
; } } } } }
但它将[choices]和[conditional_logic]保存到新数组中,我只需要[choices]


非常感谢您

因为您一直在每个foreach中使用钥匙,您可以使用它来确保它是您想要的阵列:

foreach($array as $k=>$v) {
  if (is_array($v)) {
    foreach($v as $l=>$w) {
      if ($w && $l == 'choices') { // $w is the wanted array
        foreach($w as $s=>$t) {
          $idiomas[]=$t.'<br />';
        }
      }
    }
  }
}
foreach($k=>v的数组){
if(is_数组($v)){
foreach($v为$l=>$w){
如果($w&&$l=='choices'){/$w是需要的数组
foreach($w为$s=>t){
$idiomas[]=$t.
; } } } } }

如果
($w)
,我不确定你在测试什么,尽管用你的实际数组替换
$arr
,它仍然可以工作

// your array (replace)
$arr = array(
    "required" => 0,
    "choices" => array(
        "Catalan" => "Catalan",
        "Castellano" => "Castellano",
        "Ingles" => "Ingles",
    ),  
    "default" => NULL,
);

// the empty resulting array
$new_arr = array();

foreach($arr["choices"] as $key)
    array_push($new_arr, $arr["choices"][$key]);

// your resulting array
print_r($new_arr);

您所需的数组保存在数组中
$new\u arr

$new\u array\u choices=$array[0]['choices'


我花了一段时间创建了一个。我必须手动重新创建数组。

第一个数组是否有多个元素,还是要选择每个“子”数组?
$new\u array\u choices=$array[0][choices]?@zipzit你是最棒的。简单而奇妙!!!谢谢
// your array (replace)
$arr = array(
    "required" => 0,
    "choices" => array(
        "Catalan" => "Catalan",
        "Castellano" => "Castellano",
        "Ingles" => "Ingles",
    ),  
    "default" => NULL,
);

// the empty resulting array
$new_arr = array();

foreach($arr["choices"] as $key)
    array_push($new_arr, $arr["choices"][$key]);

// your resulting array
print_r($new_arr);