我有这个值数组
$statuses = array(
'pending' => 'Pending',
'paid' => 'Received',
'failed' => 'Failed',
'withdrawn' => 'Paid Out',
'refunded' => 'Refunded'
);
然后我运行一个foreach循环:
foreach (array_reverse($output) as $row) {
echo $row->status;
}
当我在循环中回显$row->status
时,如果它等于withdrawn
,它是否会显示Paid Out
(就像在我的数组中一样)?
答案 0 :(得分:0)
是的,它绝对可以。只要$row->status
的结果与key
中的$statuses
保持一致
echo $statuses[$row->status];