当前位置: 首页>>代码示例>>PHP>>正文


PHP UTF8::utf8_strtoupper方法代码示例

本文整理汇总了PHP中UTF8::utf8_strtoupper方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::utf8_strtoupper方法的具体用法?PHP UTF8::utf8_strtoupper怎么用?PHP UTF8::utf8_strtoupper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UTF8的用法示例。


在下文中一共展示了UTF8::utf8_strtoupper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkInitials

 /**
  * Handle initials.
  * 
  * Taken from OSBib
  *
  * @see formatNames()
  * 
  * @author    Mark Grimshaw
  * @version   1
  * 
  * @param     $creator        Associative array of creator name e.g.
  * <pre>
  *    array(['surname'] => 'Grimshaw', ['firstname'] => Mark, ['initials'] => 'M N G', ['prefix'] => ))
  * </pre>
  * Initials must be space-delimited.
  *
  * @param     $initialsStyle
  * @param     $firstNameInitial
  * @return    Formatted string of initials.
  */
 function checkInitials(&$creator, $initialsStyle, $firstNameInitial)
 {
     /**
      * Format firstname
      */
     if ($creator['firstname'] && !$firstNameInitial) {
         // Full name
         $firstName = stripslashes($creator['firstname']);
     } else {
         if ($creator['firstname']) {
             $fn = split(" ", stripslashes($creator['firstname']));
             $firstTime = TRUE;
             foreach ($fn as $name) {
                 if ($firstTime) {
                     $firstNameInitialMake = UTF8::utf8_strtoupper(UTF8::utf8_substr(trim($name), 0, 1));
                     $firstTime = FALSE;
                 } else {
                     $initials[] = UTF8::utf8_strtoupper(UTF8::utf8_substr(trim($name), 0, 1));
                 }
             }
             if (isset($initials)) {
                 if ($creator['initials']) {
                     $creator['initials'] = join(" ", $initials) . ' ' . $creator['initials'];
                 } else {
                     $creator['initials'] = join(" ", $initials);
                 }
             }
         }
     }
     /**
      * Initials are stored as space-delimited characters.
      * If no initials, return just the firstname or its initial in the correct format.
      */
     if (!$creator['initials']) {
         if (isset($firstName)) {
             // full first name only
             return $firstName;
         }
         if (isset($firstNameInitialMake) && $initialsStyle > 1) {
             // First name initial with no '.'
             return $firstNameInitialMake;
         }
         if (isset($firstNameInitialMake)) {
             // First name initial with  '.'
             return $firstNameInitialMake . '.';
         }
         return '';
         // nothing here
     }
     $initialsArray = explode(' ', $creator['initials']);
     /**
      * If firstname is initial only, prepend to array
      */
     if (isset($firstNameInitialMake)) {
         array_unshift($initialsArray, $firstNameInitialMake);
     }
     if ($initialsStyle == 0) {
         // 'T. U. '
         $initials = implode('. ', $initialsArray) . '.';
     } else {
         if ($initialsStyle == 1) {
             // 'T.U.'
             $initials = implode('.', $initialsArray) . '.';
         } else {
             if ($initialsStyle == 2) {
                 // 'T U '
                 $initials = implode(' ', $initialsArray);
             } else {
                 // 'TU '
                 $initials = implode('', $initialsArray);
             }
         }
     }
     /**
      * If we have a full first name, prepend it to $initials.
      */
     if (isset($firstName)) {
         return $firstName . ' ' . $initials;
     }
     return $initials;
//.........这里部分代码省略.........
开发者ID:ricci,项目名称:papercite,代码行数:101,代码来源:bib2tpl-entry.php

示例2: utf8_ucfirst

 /**
  * This is a unicode aware replacement for ucfirst()
  *
  * @author Andrea Rossato <arossato@istitutocolli.org>
  * @see    ucfirst()
  */
 static function utf8_ucfirst($str)
 {
     $fc = UTF8::utf8_substr($str, 0, 1);
     return UTF8::utf8_strtoupper($fc) . UTF8::utf8_substr($str, 1, UTF8::utf8_strlen($str));
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:11,代码来源:UTF8.php


注:本文中的UTF8::utf8_strtoupper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。