PHP-制作所有大写字母?

PHP-制作所有大写字母?,php,string,Php,String,我不是一个PHP程序员,但在过去做过一些调整。我怎样才能在这段代码中添加一些东西,使公司、街道和城市都成为大写 protected function getCommonOrderValues($order) { $shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null; $billingAddress = $order->getBillingAddr

我不是一个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") : '', '',
    );
}

使用strtoupper功能:


使用
strtoupper

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

$shippingAddress ? strtoupper($shippingAddress->getData("company")) : '',
使用PHP的strtoupper()函数。例如:


strtoupper($shippingAddress->getData(“公司”),

参考:-1这是在浪费时间。有时你甚至可以在谷歌上搜索一些东西,如果你搜索“php所有大写字母”,你会发现strtoupper()是第一个结果。向上投票给一些不必要的向下投票。我重复一下,谷歌搜索“php制作所有大写字母”这一问题的确切标题会返回第一个结果“strtoupper()”手册页面。这是显而易见的-1A旁注:避免在这样的数组中使用三元运算符和php函数。不仅你的代码看起来像垃圾,而且将来的维护和/或重构都会很困难。完美!我自己发现了strtoupper命令,但不是一个php程序员,我不知道如何集成。谢谢。为什么要将最佳答案改为另一个答案德索里,新来的。似乎其他答案比你早2分钟就到了,但我错过了。我会确保下次正确选择第一个“最佳”答案。
    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") : '', '',
    );
}