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


PHP mb_convert_case函数代码示例

本文整理汇总了PHP中mb_convert_case函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_convert_case函数的具体用法?PHP mb_convert_case怎么用?PHP mb_convert_case使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: strtoupperTR

 /**
  * Turkish uppercase function due to "İ" and "i" clash.
  * 
  * @see http://php.net/manual/en/ref.mbstring.php
  * 
  * @param string $str
  * @param string $encoding 
  * @return string
  */
 function strtoupperTR($str, $encoding = null)
 {
     if ($encoding) {
         mb_internal_encoding($encoding);
     }
     return mb_convert_case($str, MB_CASE_UPPER);
 }
开发者ID:mtkocak,项目名称:tckimlik,代码行数:16,代码来源:Tckimlik.php

示例2: txp_ucfirst

function txp_ucfirst($str)
{
    if (TXP_USE_MBSTRING) {
        return mb_convert_case(mb_substr($str, 0, 1), MB_CASE_UPPER) . mb_convert_case(mb_substr($str, 1), MB_CASE_LOWER);
    }
    return ucfirst($str);
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:7,代码来源:txplib_str.php

示例3: beautifulProperName

 /**
  * Metodo responsavel em retornar uma expressao no formato de nome proprio.
  *
  * @example \CoreZend\Util\String::beautifulProperName('INSTITUTO NACIONAL DE ESTUDOS E PESQUISAS EDUCACIONAIS ANÍSIO TEIXEIRA') <br /> \CoreZend\Util\String::beautifulProperName('instituto nacional de estudos e pesquisas educacionais anísio teixeira')
  *
  * @param string $strName
  * @param boolean $booSort
  * @return string
  */
 public static function beautifulProperName($strName, $booSort = false)
 {
     $strEncode = 'UTF-8';
     if (function_exists('mb_convert_case')) {
         $strName = mb_convert_case($strName, MB_CASE_TITLE, $strEncode);
     } else {
         $strName = self::utf8Decode($strName);
     }
     $strNameResult = '';
     $arrName = explode(' ', $strName);
     $arrIntersectName = array('da', 'das', 'de', 'des', 'di', 'dis', 'do', 'dos', 'du', 'dus', 'na', 'nas', 'ne', 'nes', 'ni', 'nis', 'no', 'nos', 'nu', 'nus');
     foreach ($arrName as $strBlockName) {
         $strBlockNameLower = mb_strtolower($strBlockName, $strEncode);
         $boolUcfirst = !in_array($strBlockNameLower, $arrIntersectName);
         $strNameResult .= $boolUcfirst ? ucfirst($strBlockNameLower) : $strBlockNameLower;
         $strNameResult .= ' ';
     }
     $strNameResult = trim($strNameResult);
     if ($booSort) {
         $arrNameResult = explode(' ', $strNameResult);
         $arrNameResultShort = array();
         if (isset($arrNameResult[0])) {
             $arrNameResultShort[] = $arrNameResult[0];
         }
         if (isset($arrNameResult[1])) {
             $arrNameResultShort[] = $arrNameResult[1];
         }
         if (in_array(strtolower($arrNameResult[1]), $arrIntersectName) && isset($arrNameResult[2])) {
             $arrNameResultShort[] = $arrNameResult[2];
         }
         $strNameResult = implode(' ', $arrNameResultShort);
     }
     return $strNameResult;
 }
开发者ID:ualisonaguiar,项目名称:shome2,代码行数:43,代码来源:String.php

示例4: mb_ucwords

 /**
  * The Unicode version of ucwords().
  *
  * @param string $string the input string
  * @param string $encoding default null the character encoding, if omitted the the PHP internal encoding is used
  * @return string
  */
 public static function mb_ucwords($string, $encoding = null)
 {
     if ($encoding === null) {
         $encoding = mb_internal_encoding();
     }
     return mb_convert_case($string, MB_CASE_TITLE, $encoding);
 }
开发者ID:opensolutions,项目名称:oss-framework,代码行数:14,代码来源:String.php

示例5: searchUsersAutocompleteAction

 /**
  * Esta funcion permite realizar una busqueda de usuarios que se pueden invitar a un
  * proyecto determinado mediante un autocompletar
  * @param Request $request datos de la solicitud
  * @return JsonResponse
  */
 public function searchUsersAutocompleteAction(Request $request)
 {
     //palabra buscada
     $originalTerm = $request->query->get('term');
     $term = mb_convert_case('%' . $originalTerm . '%', MB_CASE_TITLE, "UTF-8");
     $projectId = null;
     if (!empty($request->get('projectId'))) {
         $projectId = $request->get('projectId');
     }
     $em = $this->getDoctrine()->getManager();
     $users = $em->getRepository('BackendBundle:User')->findUsersAutocomplete($term, $projectId);
     if (empty($users)) {
         if (!$projectId) {
             $noMemberMessage = "* " . $originalTerm . $this->get('translator')->trans('backend.user_project.not_a_member');
         } else {
             $noMemberMessage = "* " . $originalTerm . $this->get('translator')->trans('backend.user_project.not_a_project_member');
         }
         $emptyItem['id'] = 0;
         $emptyItem['label'] = $noMemberMessage;
         $emptyItem['value'] = $noMemberMessage;
         $users[0] = $emptyItem;
     }
     $response = new JsonResponse($users);
     return $response;
 }
开发者ID:cesar-giraldo,项目名称:agile-scrum,代码行数:31,代码来源:UserController.php

示例6: isPalindrome

function isPalindrome($str)
{
    $temp = mb_convert_case($str, MB_CASE_LOWER, "UTF-8");
    $temp = preg_replace('/\\s+/', '', $temp);
    $tempRev = utf8_strrev($temp);
    return $tempRev == $temp ? mb_strlen($temp, "UTF-8") : false;
}
开发者ID:Goerik,项目名称:Tasks-on-Interview,代码行数:7,代码来源:pal.php

示例7: BuildSentence

 public function BuildSentence($string)
 {
     $string = mb_convert_case($string, MB_CASE_LOWER, 'UTF-8');
     $string = $this->mb_ucfirst($string);
     $string .= '. ';
     return $string;
 }
开发者ID:Anruin,项目名称:Tales,代码行数:7,代码来源:Storyteller.php

示例8: filter

 public function filter(array $terms)
 {
     for ($i = 0, $max = sizeof($terms); $i < $max; $i++) {
         $terms[$i] = mb_convert_case($terms[$i], nc_search::get_setting('FilterStringCase'), 'UTF-8');
     }
     return $terms;
 }
开发者ID:Blu2z,项目名称:implsk,代码行数:7,代码来源:case.php

示例9: onTicketCreated

 function onTicketCreated($answer)
 {
     try {
         global $ost;
         if (!($ticket = Ticket::lookup($answer->object_id))) {
             die('Unknown or invalid ticket ID.');
         }
         //Slack payload
         $payload = array('attachments' => array(array('pretext' => "New Ticket <" . $ost->getConfig()->getUrl() . "scp/tickets.php?id=" . $ticket->getId() . "|#" . $ticket->getId() . "> in " . Format::htmlchars($ticket->getDept() instanceof Dept ? $ticket->getDept()->getName() : '') . " via " . $ticket->getSource() . " (" . Format::db_datetime($ticket->getCreateDate()) . ")", 'fallback' => "New Ticket <" . $ost->getConfig()->getUrl() . "scp/tickets.php?id=" . $ticket->getId() . "|#" . $ticket->getId() . "> in " . Format::htmlchars($ticket->getDept() instanceof Dept ? $ticket->getDept()->getName() : '') . " via " . $ticket->getSource() . " (" . Format::db_datetime($ticket->getCreateDate()) . ")", 'color' => "#D00000", 'fields' => array(array('title' => "From: " . mb_convert_case(Format::htmlchars($ticket->getName()), MB_CASE_TITLE) . " (" . $ticket->getEmail() . ")", 'value' => '', 'short' => false)))));
         //Curl to webhook
         $data_string = utf8_encode(json_encode($payload));
         $url = $this->getConfig()->get('slack-webhook-url');
         if (!function_exists('curl_init')) {
             error_log('osticket slackplugin error: cURL is not installed!');
         }
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         $result = curl_exec($ch);
         if ($result === false) {
             error_log($url . ' - ' . curl_error($ch));
         } else {
             $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
             if ($statusCode != '200') {
                 error_log($url . ' Http code: ' . $statusCode);
             }
         }
         curl_close($ch);
     } catch (Exception $e) {
         error_log('Error posting to Slack. ' . $e->getMessage());
     }
 }
开发者ID:Quivr,项目名称:osticket-slack,代码行数:34,代码来源:slack.php

示例10: getByQuery

    public function getByQuery($args)
    {
        $dql = "
            SELECT PARTIAL s.{id, title} FROM n3b\Bundle\Kladr\Entity\KladrStreet s
            JOIN s.parent r WITH r.id = :region
            WHERE s.title LIKE :query
            ORDER BY s.title";
        $count = "
            SELECT COUNT(s) FROM n3b\Bundle\Kladr\Entity\KladrStreet s
            JOIN s.parent r WITH r.id = :region
            WHERE s.title LIKE :query";

        $q = $this->getEntityManager()->createQuery($dql);
        $q->setParameters(array(
            'query' => \mb_convert_case($args['query'], MB_CASE_TITLE, "UTF-8") . '%',
            'region' => $args['region']
        ));
        $qCount = $this->getEntityManager()->createQuery($count);
        $qCount->setParameters(array(
            'query' => \mb_convert_case($args['query'], MB_CASE_TITLE, "UTF-8") . '%',
            'region' => $args['region']
        ));
        
        $q->setMaxResults(10);
        $res['count'] = $qCount->getSingleScalarResult();
        $res['items'] = $q->getArrayResult();

        return $res;
    }
开发者ID:n3b,项目名称:Symfony2-KladrBundle,代码行数:29,代码来源:StreetRepository.php

示例11: __construct

 function __construct($username)
 {
     $query = mysql_query("SELECT * FROM `users` WHERE `username` = '{$username}'");
     if ($user = mysql_fetch_object($query)) {
         $this->username = $user->username;
         $this->password = $user->password;
         $this->display_name = $user->display_name;
         $this->avatar = $user->avatar;
         $this->active = $user->active;
         $this->timezone = $user->timezone;
         $this->region = $user->region;
         $this->language = $user->language;
         $this->role = $user->role;
         $this->exp = $user->exp;
         $this->gold = $user->gold;
         $this->color = $user->color;
         $this->last_seen = $user->last_seen;
         $this->last_awarded = $user->last_awarded;
         $this->last_activity = $user->last_activity;
         $this->dob = $user->dob;
         $this->email = $user->email;
         $this->address = strtoupper($user->address);
         $this->phone_home = $user->phone_home;
         $this->phone_cell = $user->phone_cell;
         $this->name_last = $user->name_last;
         $this->name_middle = $user->name_middle;
         $this->name_first = $user->name_first;
         $this->you = mb_convert_case($user->you, MB_CASE_TITLE, "UTF-8");
         $this->me = mb_convert_case($user->me, MB_CASE_TITLE, "UTF-8");
         $this->post_you = mb_convert_case($user->you, MB_CASE_TITLE, "UTF-8");
         $this->post_me = mb_convert_case($user->me, MB_CASE_TITLE, "UTF-8");
         list($this->dob_date, $this->dob_time) = explode(" ", $this->dob);
         list($this->dob_year, $this->dob_month, $this->dob_day) = explode("-", $this->dob_date);
         if (isset($_SESSION["user"])) {
             $this->current_user = mysql_fetch_object(mysql_query("SELECT * FROM `users` WHERE `username` = '{$_SESSION["user"]}'"));
         }
         $this->title = "";
         $ignore = array("con", "em", "cháu");
         $title_only = array("ông ngoại", "ông nội", "ba", "bà ngoại", "bà nội", "má");
         if (isset($this->current_user) and $this->current_user->username != $this->username) {
             $select = mysql_query("SELECT * FROM `users_titles_you` WHERE `user` = '{$this->current_user->username}'");
             if ($row = mysql_fetch_assoc($select)) {
                 if (!in_array($row[$this->username], $ignore)) {
                     $this->title = mb_convert_case($row[$this->username], MB_CASE_TITLE, "UTF-8");
                     $this->post_you = mb_convert_case($row[$this->username], MB_CASE_TITLE, "UTF-8");
                 }
             }
             $select = mysql_query("SELECT * FROM `users_titles_me` WHERE `user` = '{$this->current_user->username}'");
             if ($row = mysql_fetch_assoc($select)) {
                 $this->post_me = ucfirst($row[$this->username]);
             }
         }
         $this->name = !empty($this->title) ? !in_array(mb_convert_case($this->title, MB_CASE_LOWER, "UTF-8"), $title_only) ? mb_convert_case($this->title, MB_CASE_TITLE, "UTF-8") . " " . $this->display_name : mb_convert_case($this->title, MB_CASE_TITLE, "UTF-8") : $this->display_name;
         $this->name2 = !empty($this->title) ? !in_array(mb_convert_case($this->title, MB_CASE_LOWER, "UTF-8"), $title_only) ? mb_convert_case($this->title, MB_CASE_TITLE, "UTF-8") . " " . $this->name_first : mb_convert_case($this->title, MB_CASE_TITLE, "UTF-8") : $this->name_first;
         $this->post_name = !empty($this->title) ? !in_array(mb_convert_case($this->title, MB_CASE_LOWER, "UTF-8"), $title_only) ? mb_convert_case($this->post_you, MB_CASE_TITLE, "UTF-8") . " " . $this->display_name : mb_convert_case($this->post_you, MB_CASE_TITLE, "UTF-8") : $this->display_name;
         $this->post_name2 = !empty($this->title) ? !in_array(mb_convert_case($this->title, MB_CASE_LOWER, "UTF-8"), $title_only) ? mb_convert_case($this->post_you, MB_CASE_TITLE, "UTF-8") . " " . $this->name_first : mb_convert_case($this->post_you, MB_CASE_TITLE, "UTF-8") : $this->name_first;
     } else {
         unset($this);
     }
 }
开发者ID:khoa002,项目名称:gocxoai-cms,代码行数:60,代码来源:class.user.php

示例12: slugify

 public function slugify($name)
 {
     $slug = mb_convert_case($name, MB_CASE_LOWER, mb_detect_encoding($name));
     $slug = str_replace(' ', '-', $slug);
     $slug = str_replace('--', '-', $slug);
     return $slug;
 }
开发者ID:olivier1980,项目名称:FPNTagBundle,代码行数:7,代码来源:Slugifier.php

示例13: generateSentences

 public function generateSentences()
 {
     for ($i = 0; $i < $this->passwordsCount; $i++) {
         $number = $this->generateNumber();
         $ps_type = $this->getPluralType($number);
         $subject = $this->getSubject($ps_type);
         $words[1] = $subject['word'];
         if ($this->wordsCount == 2 or $this->wordsCount == 4 or $this->wordsCount == 5) {
             $attribute1 = $this->getAttribute1($ps_type, $ps_type == 2 ? "-" : $subject['g']);
             $words[0] = $attribute1['word'];
         }
         if ($this->wordsCount == 3 or $this->wordsCount == 4 or $this->wordsCount == 5) {
             $predicate = $this->getPredicate($subject['ps'], $subject['ps'] == "p" ? "-" : $subject['g']);
             $words[2] = $predicate['word'];
             $object = $this->getObject();
             $words[4] = $object['word'];
         }
         if ($this->wordsCount == 5) {
             $attribute2 = $this->getAttribute2($object['ps'], $object['g'], $object['alt_case']);
             $words[3] = $attribute2['word'];
         }
         ksort($words);
         $sentence = array();
         if ($number > 1) {
             $sentence[] = $number;
         }
         foreach ($words as $word) {
             if ($this->upperCaseLetter) {
                 $word = mb_convert_case($word, MB_CASE_TITLE);
             }
             $sentence[] = $word;
         }
         $this->passwords[]['sentence'] = implode(" ", $sentence);
     }
 }
开发者ID:and-rom,项目名称:androm-ru,代码行数:35,代码来源:passwordGenerator.class.php

示例14: parseToTimedSentences

 public function parseToTimedSentences($plaintext)
 {
     $srt = $this->parse($plaintext);
     $missingSentenceEnds = count(array_filter($srt, function ($row) {
         return preg_match(self::CHAR_END, $row[2]);
     })) < count($srt) / 6;
     $result = [];
     $sentence = NULL;
     $time = NULL;
     $lastCharEndedSentence = FALSE;
     foreach ($srt as list($start, $end, $text)) {
         if (!$text) {
             continue;
         }
         $text = preg_replace('~\\s+~u', ' ', $text);
         $startsWithUppercase = $text[0] === mb_convert_case($text[0], MB_CASE_UPPER);
         if ($time === NULL) {
             $time = $start;
         }
         if (($lastCharEndedSentence || $missingSentenceEnds) && $startsWithUppercase) {
             $result[] = ['time' => $time, 'sentence' => $sentence];
             $time = NULL;
             $sentence = NULL;
         }
         $sentence = trim("{$sentence} {$text}", ' ');
         $lastCharEndedSentence = (bool) preg_match(self::CHAR_END, $text);
     }
     if ($sentence) {
         $result[] = ['time' => $time, 'sentence' => $sentence];
     }
     return $result;
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:32,代码来源:Srt.php

示例15: formatString

 /**
  * Format a string data.
  *
  * @param string $str A string.
  *
  * @return string
  */
 protected function formatString($str)
 {
     if (extension_loaded('mbstring')) {
         $originalStr = $str;
         $str = mb_convert_case($str, MB_CASE_TITLE, 'UTF-8');
         // Correct for MB_TITLE_CASE's insistence on uppercasing letters
         // immediately preceded by numerals, eg: 1st -> 1St
         $originalEncoding = mb_regex_encoding();
         mb_regex_encoding('UTF-8');
         // matches an upper case letter character immediately preceded by a numeral
         mb_ereg_search_init($str, '[0-9]\\p{Lu}');
         while ($match = mb_ereg_search_pos()) {
             $charPos = $match[0] + 1;
             // Only swap it back to lowercase if it was lowercase to begin with
             if (mb_ereg_match('\\p{Ll}', $originalStr[$charPos])) {
                 $str[$charPos] = mb_strtolower($str[$charPos]);
             }
         }
         mb_regex_encoding($originalEncoding);
     } else {
         $str = $this->lowerize($str);
         $str = ucwords($str);
     }
     $str = str_replace('-', '- ', $str);
     $str = str_replace('- ', '-', $str);
     return $str;
 }
开发者ID:edwinflores,项目名称:geolocation-goal,代码行数:34,代码来源:AbstractResult.php


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