[英]How to get the value of specific array in php
I have this code in woocommerce using php. I do print_r($meta[1]) and it has output below我使用 php 在 woocommerce 中使用此代码。我执行 print_r($meta[1]) 并且下面有 output
WC_Meta_Data Object ( [current_data:protected] => Array ( [id] => 455885 [key] => _end_date_custom_field [value] => 2023-01-18 ) [data:protected] => Array ( [id] => 455885 [key] => _end_date_custom_field [value] => 2023-01-18 ) )
How can get the value of [value] key?如何获取 [value] 键的值? I tried different combinations but not working
我尝试了不同的组合但没有用
i tried echo($meta[1][value]);我试过 echo($meta[1][value]); but it is not working what did i do wrong?
但它不起作用我做错了什么?
Looking at the WooCommerce docs , the WC_Meta_Data
class has implemented the __get
magic method and has the comment Returns the value of any property.
查看WooCommerce 文档,
WC_Meta_Data
class 已经实现了__get
魔法方法,并且有评论Returns the value of any property.
, so I would assume you could do: ,所以我假设你可以这样做:
$meta[1]->value
Cheers干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.