2011-04-25 44 views
-4

我不是一个PHP程序员,但已经调整了一些过去。我如何在这段代码中添加一些东西来让公司,街道和城市都成为大写字母?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") : '', '', 
    ); 
} 
+0

'strtoupper()'? – 2011-04-25 14:54:11

+0

参考:[PHP的字符串函数](http://www.php.net/manual/en/ref.strings.php) – 2011-04-25 14:54:42

+3

-1这是浪费时间。有时你甚至可以用谷歌的东西,如果你搜索“php全部大写”,你会发现strtoupper()作为第一个结果。 – gd1 2011-04-25 14:55:58

回答

4

使用strtoupper

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

变为:

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

完美!我自己找到了strtoupper命令,但不是一个php编码器,我不知道如何整合。谢谢。 – chitown 2011-04-25 15:43:35

0

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

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

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") : '', '', 
    ); 
} 
+0

不客气。 – 2011-04-25 15:43:55

+0

为什么要改变另一个答案的最佳答案? :D – 2011-04-25 15:49:57

+0

对不起,这里新增。看起来像其他答案抵达前2分钟,但我错过了它。我将确保下次正确选择第一个“最佳”答案。 – chitown 2011-04-25 15:54:55