【发布时间】:2026-01-01 04:30:01
【问题描述】:
我正在编辑 Woocommerce 功能以显示不同语言的不同文本。我对物体不熟悉,所以求助。
我需要在多维数组中插入一个变量,但是由于它是一个对象,我一直无法通过array_push来完成。
我的目标是将 $cmets_placeholder 的值插入到数组键 'placeholder' 中。
这是当前代码:
$this->fields = array(
'billing' => WC()->countries->get_address_fields(
$billing_country,
'billing_'
),
'shipping' => WC()->countries->get_address_fields(
$shipping_country,
'shipping_'
),
'account' => array(),
'order' => array(
'order_comments' => array(
'type' => 'textarea',
'class' => array( 'notes' ),
'label' => __( 'Order notes', 'woocommerce' ),
'placeholder' => '',
),
);
array_push($this["order"]["order_comments"]["placeholder"]) = $comments_placeholder;
谢谢!
【问题讨论】:
标签: php arrays wordpress object woocommerce