本文整理汇总了PHP中UTF8::strtolower方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::strtolower方法的具体用法?PHP UTF8::strtolower怎么用?PHP UTF8::strtolower使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::strtolower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: __set
/**
* Magic setter
*
* @param string $key
* @param mixed $value
*/
public function __set($key, $value)
{
switch ($key) {
// Date of birth
case 'dob':
$value = Date::format(Date::DATE_SQL, $value);
break;
// Always lowercase e-mail
// Always lowercase e-mail
case 'email':
$value = UTF8::strtolower($value);
break;
// Hash password
// Hash password
case 'password':
$visitor = Visitor::instance();
$value = $visitor->hash_password($value);
break;
// Set cleaned username when setting username
// Set cleaned username when setting username
case 'username':
$this->username_clean = Text::clean($value);
break;
}
parent::__set($key, $value);
}
示例3: _str_ireplace
/**
* UTF8::str_ireplace
*
* @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2010 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _str_ireplace($search, $replace, $str, & $count = NULL)
{
if (UTF8::is_ascii($search) AND UTF8::is_ascii($replace) AND UTF8::is_ascii($str))
return str_ireplace($search, $replace, $str, $count);
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = UTF8::str_ireplace($search, $replace, $val, $count);
}
return $str;
}
if (is_array($search))
{
$keys = array_keys($search);
foreach ($keys as $k)
{
if (is_array($replace))
{
if (array_key_exists($k, $replace))
{
$str = UTF8::str_ireplace($search[$k], $replace[$k], $str, $count);
}
else
{
$str = UTF8::str_ireplace($search[$k], '', $str, $count);
}
}
else
{
$str = UTF8::str_ireplace($search[$k], $replace, $str, $count);
}
}
return $str;
}
$search = UTF8::strtolower($search);
$str_lower = UTF8::strtolower($str);
$total_matched_strlen = 0;
$i = 0;
while (preg_match('/(.*?)'.preg_quote($search, '/').'/s', $str_lower, $matches))
{
$matched_strlen = strlen($matches[0]);
$str_lower = substr($str_lower, $matched_strlen);
$offset = $total_matched_strlen + strlen($matches[1]) + ($i * (strlen($replace) - 1));
$str = substr_replace($str, $replace, $offset, strlen($search));
$total_matched_strlen += $matched_strlen;
$i++;
}
$count += $i;
return $str;
}
示例4: action_tag
/**
* Retrieve a JSON object containing autocomplete suggestions for existing users.
*/
public function action_tag()
{
$string = $this->request->param('string', FALSE);
$type = $this->request->param('type', 'blog');
// The user enters a comma-separated list of tags. We only autocomplete the last tag.
$tags_typed = Tags::explode($string);
$tag_last = UTF8::strtolower(array_pop($tags_typed));
$matches = array();
if (!empty($tag_last)) {
$query = DB::select('name')->from('tags')->where('name', 'LIKE', $tag_last . '%')->where('type', '=', $type);
// Do not select already entered terms.
if (!empty($tags_typed)) {
$query->where('name', 'NOT IN', $tags_typed);
}
$result = $query->limit('10')->execute();
$prefix = count($tags_typed) ? implode(', ', $tags_typed) . ', ' : '';
foreach ($result as $tag) {
$n = $tag['name'];
// Tag names containing commas or quotes must be wrapped in quotes.
if (strpos($tag['name'], ',') !== FALSE or strpos($tag['name'], '"') !== FALSE) {
$n = '"' . str_replace('"', '""', $tag['name']) . '"';
} else {
$matches[$prefix . $n] = Text::plain($tag['name']);
}
}
}
$this->response->body(JSON::encode($matches));
}
示例5: slug
/**
* Returns a string with all spaces converted to underscores (by default), accented
* characters converted to non-accented characters, and non word characters removed.
*
* @static
*
* @param $string the string you want to slug
* @param string $replacement will replace keys in map
* @param bool $tolower все в нижний регистр
*
* @return mixed
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::slug
*/
public static function slug($string, $replacement = '-', $tolower = false)
{
$string = $tolower ? UTF8::strtolower($string) : $string;
$quoted_replacement = preg_quote($replacement, '/');
$merge = ['/[^\\s\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nd}]/mu' => ' ', '/\\s+/' => $replacement, sprintf('/^[%s]+|[%s]+$/', $quoted_replacement, $quoted_replacement) => ''];
$map = self::$_transliteration + $merge;
return preg_replace(array_keys($map), array_values($map), $string);
}
示例6: _strcasecmp
/**
* UTF8::strcasecmp
*
* @package JsonApiApplication
* @author JsonApiApplication Team
* @copyright (c) 2007-2012 JsonApiApplication Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strcasecmp($str1, $str2)
{
if (UTF8::is_ascii($str1) and UTF8::is_ascii($str2)) {
return strcasecmp($str1, $str2);
}
$str1 = UTF8::strtolower($str1);
$str2 = UTF8::strtolower($str2);
return strcmp($str1, $str2);
}
示例7: title
public static function title($title, $separator = '-', $ascii_only = FALSE)
{
if ($ascii_only === TRUE) {
$title = UTF8::transliterate_to_ascii($title);
$title = preg_replace('![^' . preg_quote($separator) . 'a-z0-9\\s]+!', '', strtolower($title));
} else {
$title = preg_replace('![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u', '', UTF8::strtolower($title));
}
$title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title);
return trim($title, $separator);
}
示例8: _prepare_data
protected function _prepare_data($title, $content = '')
{
if (is_array($content)) {
$content = implode(' ', $content);
}
if (is_array($title)) {
$title = implode(' ', $title);
}
$title = UTF8::strtolower($title);
$content = UTF8::strtolower($content);
$title = $this->_get_stemmed_text($title);
$content = $this->_get_stemmed_text($content);
return array($title, $content);
}
示例9: clean_file_name
function clean_file_name($file_name, $separator = '-', $lowercase = false, $language = NULL)
{
$extension = UTF8::strtolower(extension($file_name));
if ($extension != '') {
$file_name = substr($file_name, 0, -(strlen($extension) + 1));
}
$file_name = url_title($file_name, $separator, $lowercase, true, $language);
if ($file_name == '') {
$file_name = 'file';
}
if ($extension != '') {
$file_name .= '.' . $extension;
}
return $file_name;
}
示例10: _stristr
/**
* UTF8::stristr
*
* @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2011 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _stristr($str, $search)
{
if (UTF8::is_ascii($str) and UTF8::is_ascii($search)) {
return stristr($str, $search);
}
if ($search == '') {
return $str;
}
$str_lower = UTF8::strtolower($str);
$search_lower = UTF8::strtolower($search);
preg_match('/^(.*?)' . preg_quote($search_lower, '/') . '/s', $str_lower, $matches);
if (isset($matches[1])) {
return substr($str, strlen($matches[1]));
}
return FALSE;
}
示例11: stem_query
/**
*
* @param string $keyword
* @return string
*/
public function stem_query($keyword)
{
$result = '';
$text = UTF8::strtolower($keyword);
$text = trim($text);
$text = strip_tags($text);
$stop_words = Model_Search_Stopwords::get();
// Parse original text and stem all words that are not tags
$tkn = new Model_Search_Tokenizer();
$tkn->set_text($text);
$tkn->stopwords = $stop_words;
$stemmer = new Model_Search_Stemmer($tkn);
while ($cur = $tkn->next()) {
$result .= $stemmer->stem($cur);
}
return $result;
}
示例12: model_name
/**
* Extract model name from model.
*
* Model::model_name('Model_User') => 'user'
* Model_User::model_name() => 'user'
*
* @static
* @param string|Model $model
* @return string
*
* @throws Kohana_Exception
*/
public static function model_name($model = null)
{
if (is_null($model)) {
// Get current model
$model = get_called_class();
} else {
if (is_object($model)) {
// Model is a model
$model = get_class($model);
} else {
if (!is_string($model)) {
// Invalid
throw new Kohana_Exception(':model is not a proper model.', array(':model' => $model));
}
}
}
$model = UTF8::strtolower($model ? $model : get_called_class());
return strpos($model, $prefix = 'model_') === 0 ? substr($model, strlen($prefix)) : $model;
}
示例13: getUnique
/**
* Generate a unique filename to avoid conflicts
*
* @since 1.0.1
*
* @param string $name Filename [Optional]
* @param integer $length Length of filename to return [Optional]
* @param boolean $remove_spaces Remove spaces from file name [Optional]
* @param string $replacement Replacement for spaces [Optional]
*
* @return string
*
* @uses Text::random
* @uses UTF8::strtolower
*/
public static function getUnique($name = NULL, $length = 20, $remove_spaces = TRUE, $replacement = '_')
{
if (is_null($name)) {
return UTF8::strtolower(uniqid() . Text::random('alnum', (int) $length));
} else {
// Find the file extension
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
// Remove the extension from the filename
$name = substr($name, 0, -(strlen($ext) + 1));
$retval = uniqid() . ($remove_spaces ? preg_replace('/\\s+/u', $replacement, $name) : $name);
$retval = is_null($length) ? $retval : substr($retval, 0, (int) $length);
$retval = $retval . '.' . $ext;
return $retval;
}
}
示例14: create_hash
/**
* Creates a hash value from a provided e-mail address.
* @link https://en.gravatar.com/site/implement/hash/
*
* @param string $email A registered email.
* @return string/null The hash for accessing the avatar or profile data.
*/
public function create_hash($email)
{
// Modified by Deepak Patil <deepak.patil@relesol.com>, 09-JAN-2015.
//return md5(strtolower(trim($email)));
return md5(UTF8::strtolower(trim($email)));
//
}
示例15: 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))));
}