本文整理汇总了PHP中Patchwork\Utf8::strtolower方法的典型用法代码示例。如果您正苦于以下问题:PHP Utf8::strtolower方法的具体用法?PHP Utf8::strtolower怎么用?PHP Utf8::strtolower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patchwork\Utf8
的用法示例。
在下文中一共展示了Utf8::strtolower方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: urlSafe
/**
* Convert a string to a URL safe string
*
* @param string $str
* @param array $replace
* @param string $separator
* @return string
*/
protected function urlSafe($str, $replace = array(), $separator = '-')
{
if (!empty($replace)) {
$str = str_replace((array) $replace, ' ', $str);
}
// Transliterate non-ASCII characters
// $str = UTF8::transliterate_to_ascii($str);
// Remove all characters that are not the separator, a-z, 0-9, or whitespace
$str = preg_replace('![^' . preg_quote($separator) . 'a-z0-9\\s]+!', '', UTF8::strtolower($str));
// Replace all separator characters and whitespace by a single separator
$str = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $str);
// Trim separators from the beginning and end
return trim($str, $separator);
}
示例2: testStrCase
/**
* @covers Patchwork\Utf8::strtolower
* @covers Patchwork\Utf8::strtoupper
*/
function testStrCase()
{
$this->assertSame('déjà σσς', u::strtolower('DÉJÀ Σσς'));
$this->assertSame('DÉJÀ ΣΣΣ', u::strtoupper('Déjà Σσς'));
}
示例3: api_strtolower
/**
* Makes a string lowercase.
* @param string $string The string being lowercased.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return string Returns the string with all alphabetic characters converted to lowercase.
* This function is aimed at replacing the functions strtolower() and mb_strtolower() for human-language strings.
* @link http://php.net/manual/en/function.strtolower
* @link http://php.net/manual/en/function.mb-strtolower
*/
function api_strtolower($string, $encoding = null)
{
return Utf8::strtolower($string);
}
示例4: lower
public function lower()
{
$this->string = u::strtolower($this->string);
return $this;
}
示例5: utf8_strtolower
/**
* Make a string lowercase
*
* @param string $str
*
* @return string
*
* @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
* Use Patchwork\Utf8::strtolower() instead.
*/
function utf8_strtolower($str)
{
@trigger_error('Using utf8_strtolower() has been deprecated and will no longer work in Contao 5.0. Use Patchwork\\Utf8::strtolower() instead.', E_USER_DEPRECATED);
return Utf8::strtolower($str);
}
示例6: searchFor
/**
* Search the index and return the result object
*
* @param string $strKeywords The keyword string
* @param boolean $blnOrSearch If true, the result can contain any keyword
* @param array $arrPid An optional array of page IDs to limit the result to
* @param integer $intRows An optional maximum number of result rows
* @param integer $intOffset An optional result offset
* @param boolean $blnFuzzy If true, the search will be fuzzy
*
* @return Database\Result The database result object
*
* @throws \Exception If the cleaned keyword string is empty
*/
public static function searchFor($strKeywords, $blnOrSearch = false, $arrPid = array(), $intRows = 0, $intOffset = 0, $blnFuzzy = false)
{
// Clean the keywords
$strKeywords = Utf8::strtolower($strKeywords);
$strKeywords = \StringUtil::decodeEntities($strKeywords);
$strKeywords = preg_replace(array('/\\. /', '/\\.$/', '/: /', '/:$/', '/, /', '/,$/', '/[^\\w\' *+".:,-]/u'), ' ', $strKeywords);
// Check keyword string
if (!strlen($strKeywords)) {
throw new \Exception('Empty keyword string');
}
// Split keywords
$arrChunks = array();
preg_match_all('/"[^"]+"|[\\+\\-]?[^ ]+\\*?/', $strKeywords, $arrChunks);
$arrPhrases = array();
$arrKeywords = array();
$arrWildcards = array();
$arrIncluded = array();
$arrExcluded = array();
foreach ($arrChunks[0] as $strKeyword) {
if (substr($strKeyword, -1) == '*' && strlen($strKeyword) > 1) {
$arrWildcards[] = str_replace('*', '%', $strKeyword);
continue;
}
switch (substr($strKeyword, 0, 1)) {
// Phrases
case '"':
if (($strKeyword = trim(substr($strKeyword, 1, -1))) != false) {
$arrPhrases[] = '[[:<:]]' . str_replace(array(' ', '*'), array('[^[:alnum:]]+', ''), $strKeyword) . '[[:>:]]';
}
break;
// Included keywords
// Included keywords
case '+':
if (($strKeyword = trim(substr($strKeyword, 1))) != false) {
$arrIncluded[] = $strKeyword;
}
break;
// Excluded keywords
// Excluded keywords
case '-':
if (($strKeyword = trim(substr($strKeyword, 1))) != false) {
$arrExcluded[] = $strKeyword;
}
break;
// Wildcards
// Wildcards
case '*':
if (strlen($strKeyword) > 1) {
$arrWildcards[] = str_replace('*', '%', $strKeyword);
}
break;
// Normal keywords
// Normal keywords
default:
$arrKeywords[] = $strKeyword;
break;
}
}
// Fuzzy search
if ($blnFuzzy) {
foreach ($arrKeywords as $strKeyword) {
$arrWildcards[] = '%' . $strKeyword . '%';
}
$arrKeywords = array();
}
// Count keywords
$intPhrases = count($arrPhrases);
$intWildcards = count($arrWildcards);
$intIncluded = count($arrIncluded);
$intExcluded = count($arrExcluded);
$intKeywords = 0;
$arrValues = array();
// Remember found words so we can highlight them later
$strQuery = "SELECT tl_search_index.pid AS sid, GROUP_CONCAT(word) AS matches";
// Get the number of wildcard matches
if (!$blnOrSearch && $intWildcards) {
$strQuery .= ", (SELECT COUNT(*) FROM tl_search_index WHERE (" . implode(' OR ', array_fill(0, $intWildcards, 'word LIKE ?')) . ") AND pid=sid) AS wildcards";
$arrValues = array_merge($arrValues, $arrWildcards);
}
// Count the number of matches
$strQuery .= ", COUNT(*) AS count";
// Get the relevance
$strQuery .= ", SUM(relevance) AS relevance";
// Get meta information from tl_search
$strQuery .= ", tl_search.*";
// see #4506
//.........这里部分代码省略.........