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


PHP UTF8::trim方法代码示例

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


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

示例1: slug

 public static function slug($string, $replacement = '-')
 {
     $slug = UTF8::trim(UTF8::strtolower($string));
     $map = array('/ä/' => 'ae', '/ö/' => 'oe', '/ü/' => 'ue', '/щ/' => 'sch', '/ш/' => 'sh', '/ч/' => 'ch', '/ц/' => 'c', '/ю/' => 'yu', '/я/' => 'ya', '/ж/' => 'zh', '/а/' => 'a', '/б/' => 'b', '/в/' => 'v', '/г|ґ/' => 'g', '/д/' => 'd', '/е/' => 'e', '/ё/' => 'yo', '/з/' => 'z', '/и|і/' => 'i', '/й/' => 'y', '/к/' => 'k', '/л/' => 'l', '/м/' => 'm', '/н/' => 'n', '/о/' => 'o', '/п/' => 'p', '/р/' => 'r', '/с/' => 's', '/т/' => 't', '/у/' => 'u', '/ф/' => 'f', '/х/' => 'h', '/ы/' => 'y', '/э/' => 'e', '/є/' => 'ye', '/ї/' => 'yi', '/º|°/' => 0, '/¹/' => 1, '/²/' => 2, '/³/' => 3, '/à|á|å|â|ã|ä|ą|ă|ā|ª/' => 'a', '/@/' => 'at', '/æ/' => 'ae', '/ḃ/' => 'b', '/č|ç|¢|ć|ċ|ĉ|©/' => 'c', '/ď|ḋ|đ/' => 'd', '/€/' => 'euro', '/è|é|ê|ě|ẽ|ë|ę|ē|ė|ĕ/' => 'e', '/ƒ|ḟ/' => 'f', '/ģ|ğ|ĝ|ġ/' => 'g', '/ĥ|ħ/' => 'h', '/Ì|Í|Î|Ï/' => 'I', '/ì|í|î|ï|ĩ|ī|į|ı/' => 'i', '/ĵ/' => 'j', '/ķ/' => 'k', '/ł|ľ|ĺ|ļ/' => 'l', '/Ł/' => 'L', '/ṁ/' => 'm', '/ñ|ń|ņ|ň/' => 'n', '/ò|ó|ô|ø|õ|ö|ō|ð|ơ|ő/' => 'o', '/œ/' => 'oe', '/ṗ/' => 'p', '/ř|ŗ|ŕ|®/' => 'r', '/š|ś|ṡ|ş|ș/' => 's', '/ť|ț|ŧ|ţ|ṫ/' => 't', '/þ/' => 'th', '/ß/' => 'ss', '/™/' => 'tm', '/ù|ú|ů|û|ü|ū|ũ|ű|ŭ|ư|ų|µ/' => 'u', '/ẃ|ẅ|ẁ|ŵ/' => 'w', '/×/' => 'x', '/ÿ|ý|ỳ|ŷ|¥/' => 'y', '/Ž|Ż|Ź/' => 'Z', '/ž|ż|ź/' => 'z', '/\\s+/' => $replacement);
     $slug = preg_replace(array_keys($map), array_values($map), $slug);
     return URL::title($slug, $replacement);
 }
开发者ID:Nyaan,项目名称:meintagebuchonline,代码行数:7,代码来源:helper.php

示例2: short_story

 /**
  * Helper for create short description news
  * 
  * @param string $text
  * @param integer $limit
  * @param string $allow_tags
  * @return string
  */
 public static function short_story($text, $limit = 200, $allow_tags = NULL)
 {
     if ($allow_tags != NULL) {
         $text = strip_tags($text, $allow_tags);
     } else {
         $text = strip_tags($text);
     }
     $text = str_replace(array('–', ' ', '&', '«', '»', '\\n', '\\r'), ' ', $text);
     $text = preg_replace('/(\\r\\n|\\n|\\r)\\s*(\\r\\n|\\n|\\r)/', ' ', $text);
     $text = preg_replace('/(\\r\\n|\\n|\\r)\\s*(\\r\\n|\\n|\\r)/', ' ', $text);
     $text = preg_replace('/[ \\t]{1,}/', ' ', $text);
     $text = UTF8::trim($text);
     if ($limit > 0) {
         $text = self::limit_chars($text, $limit, NULL, TRUE);
         // $text = self::limit_words($text, $limit, NULL, TRUE);
     }
     // $text = HTML::chars($text);
     return $text;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:27,代码来源:text.php

示例3: SendEmail

 public function SendEmail($post)
 {
     $to = $post['to'];
     if ($to == "") {
         return;
     }
     $from = $post['from'];
     $subject = $post['subject'];
     $message = $post['message'];
     //$transport = Swift_SmtpTransport::newInstance('mail.nnngo.org', 25);
     $transport = Swift_MailTransport::newInstance();
     $transport->start();
     $mailer = Swift_Mailer::newInstance($transport);
     $mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100));
     $message = Swift_Message::newInstance("{$subject}")->setFrom(array("{$from}" => "{$from}"))->setBody("{$message}", 'text/html', 'iso-8859-2');
     $message->setReturnPath($post['email']);
     $message->setSender($from);
     $message->setPriority(2);
     $message->setReplyTo($post['email']);
     $message->addTo(UTF8::trim($to));
     if (!$mailer->send($message, $failures)) {
         echo Kohana::debug($failures);
     }
 }
开发者ID:samjiks,项目名称:semedng,代码行数:24,代码来源:messagemd.php

示例4: test_trim

 /**
  * Tests UTF8::trim
  *
  * @test
  * @dataProvider provider_trim
  */
 public function test_trim($input, $input2, $expected)
 {
     $this->assertSame($expected, UTF8::trim($input, $input2));
 }
开发者ID:azuya,项目名称:Wi3,代码行数:10,代码来源:UTF8Test.php

示例5: humanize

 /**
  * Humanize
  *
  * Takes multiple words separated by the separator and changes them to spaces
  *
  * @param       string      $str            Input string
  * @param       string      $separator      Input separator
  * @return      string
  */
 function humanize($str, $separator = '_')
 {
     return UTF8::ucwords(preg_replace('/[' . preg_quote($separator) . ']+/' . (IS_UTF8_CHARSET && PCRE_UTF8_INSTALLED ? 'u' : ''), ' ', UTF8::trim(UTF8::strtolower($str))));
 }
开发者ID:roniwahyu,项目名称:starter-public-edition-3,代码行数:13,代码来源:MY_inflector_helper.php

示例6: _ensure_parm

 /**
  * Ensure a parameter is set.
  * If a parameter is not set, log an error and throw an exception (if
  * specified).
  *
  * @param	string	the parameter name
  * @param	mixed	the parameter value
  * @param	boolean	throw an exception?
  * @return	void
  */
 protected function _ensure_parm($name, $value, $throw_exception = TRUE)
 {
     if (!isset($value) or is_string($value) and UTF8::trim($value) === '' or $value === array()) {
         $service = $this->_service;
         MMI_Log::log_error(__METHOD__, __LINE__, $name . ' not set for ' . $service);
         if ($throw_exception) {
             throw new Kohana_Exception(':name not set for :service in :method.', array(':name' => $name, ':service' => $service, ':method' => __METHOD__));
         }
     }
 }
开发者ID:azuya,项目名称:mmi-api,代码行数:20,代码来源:api.php

示例7: array

			},
			node: {
				HTMLclass: 'nodeExample1'
			}
		},
		nodeStructure: {
			text: {
				name: "<?php 
echo $user->name . ' ' . $user->surname;
?>
"
				<?php 
if (Auth::instance()->get_user()->id == Request::initial()->param('user_id')) {
    ?>
				,desc: {
					val: 'Добавить родственника',
					href: '<?php 
    echo Route::url('default', array('controller' => 'user', 'action' => 'relative'));
    ?>
'
				}
				<?php 
}
?>
			},
			<?php 
echo UTF8::trim($family_json, '{}');
?>
		}
	};
</script>
开发者ID:vetalstar,项目名称:LiveTex,代码行数:31,代码来源:family.php

示例8: normalize_spaces

 /**
  * Replace runs of multiple whitespace characters with a single space
  *
  * @param   string  $string  The string to normalize
  *
  * @return  string
  *
  * @uses    UTF8::trim
  */
 public static function normalize_spaces($string)
 {
     $normalized = $string;
     if (!empty($normalized)) {
         $normalized = preg_replace('/[\\s\\n\\r\\t]+/', ' ', $string);
         $normalized = UTF8::trim($normalized);
     }
     return $normalized;
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:18,代码来源:text.php

示例9: word_limiter

 /**
  * Word Limiter, UTF-8 version.
  *
  * Limits a string to X number of words.
  *
  * @param       string
  * @param       int
  * @param       string    The end character. Usually an ellipsis
  * @return      string
  */
 function word_limiter($str, $limit = 100, $end_char = '&#8230;')
 {
     if (UTF8::trim($str) === '') {
         return $str;
     }
     // Added by Ivan Tcholakov, 08-FEB-2016.
     $end_char = html_entity_decode($end_char, ENT_QUOTES, 'UTF-8');
     //
     preg_match('/^\\s*+(?:\\S++\\s*+){1,' . (int) $limit . '}/' . (IS_UTF8_CHARSET && PCRE_UTF8_INSTALLED ? 'u' : ''), $str, $matches);
     if (UTF8::strlen($str) === UTF8::strlen($matches[0])) {
         $end_char = '';
     }
     return UTF8::rtrim($matches[0]) . $end_char;
 }
开发者ID:roniwahyu,项目名称:starter-public-edition-3,代码行数:24,代码来源:MY_text_helper.php

示例10: word_limiter

 /**
  * Word Limiter, UTF-8 version.
  *
  * Limits a string to X number of words.
  *
  * @param       string
  * @param       int
  * @param       string    The end character. Usually an ellipsis
  * @return      string
  */
 function word_limiter($str, $limit = 100, $end_char = '&#8230;')
 {
     if (UTF8::trim($str) === '') {
         return $str;
     }
     preg_match('/^\\s*+(?:\\S++\\s*+){1,' . (int) $limit . '}/' . (IS_UTF8_CHARSET && PCRE_UTF8_INSTALLED ? 'u' : ''), $str, $matches);
     if (UTF8::strlen($str) === UTF8::strlen($matches[0])) {
         $end_char = '';
     }
     return UTF8::rtrim($matches[0]) . $end_char;
 }
开发者ID:Qnatz,项目名称:starter-public-edition-4,代码行数:21,代码来源:MY_text_helper.php


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