3
PHP數組打印值我有一個數組$t1
象下面這樣:與特定條件
Array (
[0] => Array (
[cust_type] => Corporate
[trx] => 1
[amount] => 10)
[1] => Array (
[cust_type] => Non Corporate
[trx] => 2
[amount] => 20)
[2] => Array (
[cust_type] => Corporate
[trx] => 3
[amount] => 30)
[3] => Array (
[cust_type] => Non Corporate
[trx] => 4
[amount] => 40))
我想打印TRX
其cust_type = Corporate
。我使用foreach內的條件語句如下:
foreach ($t1 as $key => $value) {
if($value['cust_type'] = 'Corporate')
{
print_r($value['trx']);
}
echo "<br/>";
}
但它打印所有TRX值而不是公司只。 請幫助我,謝謝。