我有一個數組,看起來像這樣:使用數組拼接換出數組的最後一個值?
Array ([0] => Credit Card Type [1] => MasterCard)
Array ([0] => Credit Card Number [1] => xxxx-1111)
Array ([0] => Processed Amount [1] => $106.91)
Array ([0] => Transaction Id [1] => 5011056094736597703015)
Array ([0] => AVS Response [1] => Z (Street address does not match, but 5-digit postal code matches.))
Array ([0] => CVN Response [1] => M (Card verification number matched.))
Array ([0] => Merchant Reference Code [1] => 25f11646823dc7488b48c04491335936)
我使用print_r(array($_label, $_value));
顯示以上。
我想換出商戶參考碼值,這是長字母數字號碼。
這是一個Magento的構建所以我假設我會附和
$order = Mage::getModel('sales/order')->load($orderId);
echo $order->getIncrementId();
什麼將是最適當的方式GE完成這項工作?
array_splice
or array_push
?
任何幫助將不勝感激。謝謝。
<div class="cards-list">
<?php if (!$this->getHideTitle()): ?>
<div class="bold"><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></div>
<?php endif;?>
</div>
<?php
$cards = $this->getCards();
$showCount = count($cards) > 1;
?>
<?php foreach ($cards as $key => $card): ?>
<?php if ($showCount): ?>
<span><?php echo sprintf($this->__('Credit Card %s'), $key + 1); ?></span>
<?php endif;?>
<table class="info-table<?php if ($showCount):?> offset<?php endif;?>">
<tbody>
<?php foreach ($card as $_label => $_value):?>
<tr>
<td><?php echo $this->escapeHtml($_label)?>:</td>
<td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n"))?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endforeach; ?>
你能澄清你所說的 「換出」 的意思。根據你對array_splice的引用,我假設你正在尋找從你的數組中刪除「Merchant Reference Code」元素,並添加另一個元素與訂單ID? –
這是正確的@ ever.wakeful – Singleton
你可以添加生成你的'$ _label'和'$ _value'的代碼嗎? – sv3n