在多维数组中搜索



我有一个数组:

    Array
(
    [_edit_lock] => Array
        (
            [0] => 1434971582:11
        )
    [_edit_last] => Array
        (
            [0] => 11
        )
    [_wp_page_template] => Array
        (
            [0] => page-templates/langenfeldDreiSpalterMitSiderbarsRL.php
        )
    [_wpas_done_all] => Array
        (
            [0] => 1
        )
    [hefo_before] => Array
        (
            [0] => 0
        )
    [hefo_after] => Array
        (
            [0] => 0
        )
    [sharing_disabled] => Array
        (
            [0] => 1
        )
    [spacious_page_layout] => Array
        (
            [0] => left_sidebar
        )
    [_thumbnail_id] => Array
        (
            [0] => 2641
        )
    [ort] => Array
        (
            [0] => langenfeld
        )
)

我想把"ort"保存在一个变量中。

[ort] => Array
    (
        [0] => langenfeld
    )

我的代码提供了数组的值,但我如何保存这些值?我的代码:

foreach ($gpc as $k){
    foreach ($k as $v){
        //echo $v;
    }
}

我想的是:

$ort = $v['ort'];

但这对我不起作用。有人能帮忙吗?

此代码工作正常

 $arr =    Array
    (
        '_edit_lock' => Array
            (
                '0' => "1434971582:11",
            ),
        '_edit_last' => Array
            (
                '0' => "11",
            ),
        '_wp_page_template' => Array
            (
                '0' => "page-templates/langenfeldDreiSpalterMitSiderbarsRL.php",
            ),
        '_wpas_done_all' => Array
            (
                '0' => "1",
            ),
        'hefo_before' => Array
            (
                '0' => "0",
            ),
        'hefo_after' => Array
            (
                '0' => "0",
            ),
        'sharing_disabled' => Array
            (
                '0' => "1",
            ),
        'spacious_page_layout' => Array
            (
                '0' => "left_sidebar",
            ),
        '_thumbnail_id' => Array
            (
                '0' => "2641",
            ),
        'ort' => Array
            (
                '0' => "langenfeld",
            ),
    );
    $ort = $arr["ort"];
    print_r($ort);

//输出

   Array
  (
      [0] => langenfeld
   )

如果您直接想要兰根菲尔德

   $ort = $arr['ort'][0];

//这将输出-langenfeld

相关内容

  • 没有找到相关文章