dongshao2967 2018-02-09 19:00
浏览 49
已采纳

从PHP数组访问特定的元字段

I am using the following to output meta values for a current logged in user.

<?php
$user_id = get_current_user_id();
$key = 'chargebee_user_subscriptions';
$all_meta_for_user = get_user_meta( $user_id, $key, true  );
print_r($all_meta_for_user);

Output

Array ( [0] => Array ( [subscription_id] => IaQX8AtBRo [product_id] => cbdemo_grow [product_name] => Plan - Grow [product_decs] => This a 3-month plan with a 14 day trial period. [status] => in_trial [product_price] => 89 USD / 3 month [trail_start] => 08/02/2018 [trial_end] => 22/02/2018 ) )

This works great, but I only need to access a specific meta field from the array product_id.

I've attempted to output this via the following but cannot get it to work:

<?php
$all_meta_for_user['product_id'][0];
  • 写回答

2条回答 默认 最新

  • dongpa5207 2018-02-09 19:01
    关注

    You have it the wrong way around.

    $all_meta_for_user[0]['product_id'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备