PHP - 全部上限?

时间:2011-04-25 14:53:12

标签: php string

我不是PHP程序员,但过去曾调整过一些。如何在这段代码中添加一些内容,以使公司,街道和城市全部上限?

    protected function getCommonOrderValues($order) 
{
    $shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null;
    $billingAddress = $order->getBillingAddress();

    return array(
        $shippingAddress ? $shippingAddress->getData("company") : '',
        $shippingAddress ? $shippingAddress->getName() : '', '', '',
        $shippingAddress ? $shippingAddress->getData("street") : '', '', '',
        $shippingAddress ? $shippingAddress->getData("city") : '',
        $shippingAddress ? $shippingAddress->getRegionCode() : '',
        $shippingAddress ? $shippingAddress->getData("postcode") : '',
        $shippingAddress ? $shippingAddress->getCountry() : '', 'standard',
        $order->getRealOrderId(),
        $shippingAddress ? $shippingAddress->getData("telephone") : '', '',
    );
}

4 个答案:

答案 0 :(得分:4)

使用strtoupper

$shippingAddress ? $shippingAddress->getData("company") : '',

变为:

$shippingAddress ? strtoupper($shippingAddress->getData("company")) : '',

答案 1 :(得分:0)

答案 2 :(得分:0)

使用PHP的strtoupper()函数。例如:

strtoupper($shippingAddress->getData("company")),

答案 3 :(得分:0)

    protected function getCommonOrderValues($order) 
{
    $shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null;
    $billingAddress = $order->getBillingAddress();

    return array(
        $shippingAddress ? strtoupper( $shippingAddress->getData("company") ) : '',
        $shippingAddress ? $shippingAddress->getName() : '', '', '',
        $shippingAddress ? strtoupper( $shippingAddress->getData("street") ) : '', '', '',
        $shippingAddress ? strtoupper( $shippingAddress->getData("city") ) : '',
        $shippingAddress ? $shippingAddress->getRegionCode() : '',
        $shippingAddress ? $shippingAddress->getData("postcode") : '',
        $shippingAddress ? strtoupper( $shippingAddress->getCountry()  ): '', 'standard',
        $order->getRealOrderId(),
        $shippingAddress ? $shippingAddress->getData("telephone") : '', '',
    );
}