2014-08-28 113 views
-2

我有這個數組值顯示PHP數組值

$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(就像我的數組中)?

+1

你的問題是不一致的。除非你沒有給我們提供足夠的相關信息,否則它沒有任何意義。是'$ output'應該是'$ statuses'? – Seth 2014-08-28 16:29:38

回答

0

是的,它絕對可以。只要$row->status結果保持相同key$statuses

echo $statuses[$row->status]; 
+0

輝煌!謝謝! – Charlie 2014-08-28 16:44:42