dongtan1009 2016-09-07 06:46
浏览 143
已采纳

如何使用PHP自定义查询从Wordpress数据库表wp_postMeta获取数据

I am developing a custom PHP based website and attaching it with WordPress database, I want to fetch data from wp_postMeta, with custom PHP not with WordPress get_post_meta.

The major issue I am facing is to convert multidimensional array and displaying record actually I don't know about that how to convert and display .

See the picture please enter image description here

  • 写回答

2条回答 默认 最新

  • douyun7718 2016-09-07 06:59
    关注

    So you have already the query but you can't convert this serialized array into a PHP array? Just use the PHP unserialize() function. Take a look at the PHP docs.

    unserialize() converts this:

    a:2:{i:0;s:12:"Sample array";i:1;a:2:{i:0;s:5:"Apple";i:1;s:6:"Orange";}}
    

    into this:

    Array
    (
        [0] => Sample array
        [1] => Array
            (
                [0] => Apple
                [1] => Orange
            )
    
    )
    

    In your case it could be something like this.. really easy:

    $array = unserialize( $queried_data );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?