Filter some values from an array in a serialized post_meta (PHP)

前端 未结 2 1167
余生分开走
余生分开走 2021-01-24 15:21

I have setup in Wordpress a custom post type ( Artists )...

I have a plugin that serializez the meta information from the Artists .. and i need to filter this informatio

2条回答
  •  孤城傲影
    2021-01-24 15:38

    You can do it by array_filter() using any key has value.

    For e.g Channel => trance then it will return matched arrays.

    $value = 'trance';
    $key = 'channel';
    
    $show_data = array_filter($array, function($itrate) use ($value,$key) {
        return $itrate[$key] == $value;
    });
    

    See : Live Demo

提交回复
热议问题