我找到了this manual page,但我仍然不知道该用什么。我有这个数组:
Array (
[unique_key] => 7439db65fe2856a636e3c6d9841b51ed
[thwepof_options] => Array (
[order_date] => Array (
[name] => order_date
[value] => 29-01-2018, monday
[label] => Order date
[options] =>
)
)
)
字符串
所以首先我只对每个[thwepof_options] => value
进行排序,并使它们唯一(因为我只需要一次):
<?php foreach (WC()->cart->get_cart() as $order_dates => $order_date): ?>
<?php $options = $order_date['thwepof_options']; ?>
<?php foreach($options as $option => $dates): ?>
<?php array_push($myarray, $dates['value']) ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php sort($myarray); ?>
<?php $unique = array_unique($myarray); ?>
//later in that code
<?php foreach($unique as $dates => $date_value): ?>
<tr>
<h1><?php echo $date_value ?></h1></td>
</tr>
<?php endforeach; ?>
型
使用WC()->cart->get_cart()
方法我可以得到整个数组。我需要某种过滤器来删除数组中$date_value
不等于[thwepof_options] => [value]
的所有值(或者只显示那些相等的值),以创建另一个foreach
循环。
1条答案
按热度按时间mi7gmzs61#
试试这个:
字符串
由于没有提供所有的代码,因此并不完全清楚您从哪里获取所有的值,但我希望这成功地演示了一种过滤数组的简单方法。