Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从wp_Posteta检索数据_Php_Arrays_Wordpress - Fatal编程技术网

Php 从wp_Posteta检索数据

Php 从wp_Posteta检索数据,php,arrays,wordpress,Php,Arrays,Wordpress,我知道这可能是个愚蠢的问题。我试图从wordpress表wp_postemta中检索数据,特别是meta_value列。php中是否有从此类数据中获取每个字段的函数 例如,我如何从中获得“哥斯达黎加的加布里埃拉·卡斯特罗”值 a:1:{s:14:"billing-seller";a:3:{s:4:"name";s:14:"billing-seller";s:5:"value";s:29:"Gabriela Castro en Costa Rica";s:5:"label";s:26:"Selec

我知道这可能是个愚蠢的问题。我试图从wordpress表wp_postemta中检索数据,特别是meta_value列。php中是否有从此类数据中获取每个字段的函数

例如,我如何从中获得“哥斯达黎加的加布里埃拉·卡斯特罗”值

a:1:{s:14:"billing-seller";a:3:{s:4:"name";s:14:"billing-seller";s:5:"value";s:29:"Gabriela Castro en Costa Rica";s:5:"label";s:26:"Select one option, please.";}}

谢谢。

这看起来像是一个序列化数组,我不熟悉Wordpress,但可能会尝试以下方法:

get_user_meta( '99999', 'your-key', true );
您可以在此处找到获取用户元数据的更多信息:

get\u post\u meta()
是您需要使用的函数

$value = get_post_meta( $post_id, 'key', true );
其中,
$value
将是您的字符串


首先,我发布的序列化字符串来自于这样做:

get_post_meta($order->orders, '_custom_billing_fields', true);
这给了我这个(最初的问题):

这就是我所做的,以得到我试图减去的值:

$sellerBigArray = (array)maybe_unserialize(get_post_meta($order->orders, '_custom_billing_fields', true));

$sellerArray=$sellerBigArray['billing-seller'];

$seller=$sellerArray['value'];
我希望有帮助


再见

谢谢,我试过了,但在阅读文档时我发现我需要一个用户id,而我的代码没有用户id。您从哪里查询数据?插件/主题的模板functions.php文件,还是“外部”脚本?
$sellerBigArray = (array)maybe_unserialize(get_post_meta($order->orders, '_custom_billing_fields', true));

$sellerArray=$sellerBigArray['billing-seller'];

$seller=$sellerArray['value'];