【问题标题】:How to get 3 child array in main array in php如何在php的主数组中获取3个子数组
【发布时间】:2020-07-24 01:41:53
【问题描述】:

我需要 dtbl_collection_0、dtbl_collection_1 和 dtbl_collection_3 动态值获取。而且这里也没有固定 0,1,2,3,4,5,...... 这里没有 固定。

请大家帮帮我

 Array
    (
        [user_ID] => 1
        [action] => editpost
        [originalaction] => editpost
        [post_author] => 1
        [post_type] => datatable
        [original_post_status] => auto-draft
        [cur_jj] => 11
        [hidden_aa] => 2020
        [cur_aa] => 2020
        [hidden_hh] => 09
        [cur_hh] => 09
        [hidden_mn] => 49
        [cur_mn] => 49
        [original_publish] => Publish
        [publish] => Publish
        [dtbl_collection_0] => Array
            (
                [0] => 11
                [1] => 22
                [2] => 33
            )

        [dtbl_collection_1] => Array
            (
                [0] => 44
                [1] => 55
                [2] => 66
            )

        [dtbl_collection_2] => Array
            (
                [0] => 77
                [1] => 88
                [2] => 99
            )

        [post_name] => 
        [post_mime_type] => 
        [ID] => 95
        [comment_status] => closed
        [ping_status] => closed
    )

global $post;   
$dtbl_collection = get_post_meta($post->ID,'dtbl_collection',true);
if($dtbl_collection){       
    foreach ($dtbl_collection as $key => $value) {          

    }   
}

如何为 3 个数组动态键。这是我的代码如何获取它。

【问题讨论】:

  • 请将信息添加为文本,而不是图像。这很容易被复制粘贴到问题中。而且您的问题还不清楚,“如何动态键”是什么意思?你想做什么?获取价值?插入值?请添加更多详细信息。
  • 好的,我会放@El_Vanja
  • 我已经把请检查并帮助我@El_Vanja

标签: php arrays wordpress


【解决方案1】:

我在这里找到了答案

foreach ($dtbl_collection as $key => $value) {
            $strFindMe = "dtbl_collection_";
            $exists = strpos($key, $strFindMe);
            if ($exists !== false) {
                print_r($key);
            }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-26
    • 1970-01-01
    • 1970-01-01
    • 2021-10-28
    • 2017-12-05
    • 1970-01-01
    • 2021-09-26
    • 2021-08-19
    相关资源
    最近更新 更多