本文整理匯總了PHP中Inflector::unaccent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::unaccent方法的具體用法?PHP Inflector::unaccent怎麽用?PHP Inflector::unaccent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::unaccent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: urlize
function urlize($text)
{
return trim(Inflector::underscore(Inflector::unaccent($text)), '_');
}
示例2: searchBano
public function searchBano($sellzone_id, $q, $limit = 30, $offset = 0, $lat = 0, $lng = 0)
{
return call_user_func_array([$this, 'suggestAddressBySellzone'], func_get_args());
if (fnmatch('* *', $q)) {
$tab = explode(' ', $q);
$first = Arrays::first($tab);
if (is_numeric($first)) {
$number = true;
array_shift($tab);
$q = implode(' ', $tab);
}
}
$keyCache = 'l.cachersBanos.' . sha1(serialize(func_get_args()));
$collection = redis()->get($keyCache);
$cachedZip = redis()->get('zips.covered.' . $sellzone_id);
if (!$cachedZip) {
$coll = [];
$zips = Model::Coveredcity()->where(['sellzone_id', '=', (int) $sellzone_id])->cursor();
foreach ($zips as $zip) {
$coll[] = $zip['zip'];
}
redis()->set('zips.covered.' . $sellzone_id, serialize($coll));
$cachedZip = $coll;
} else {
$cachedZip = unserialize($cachedZip);
}
$sz = Model::Sellzone()->refresh()->find((int) $sellzone_id);
$lat = 0 < $lat ? $lat : (double) $sz->latitude;
$lng = 0 < $lng ? $lng : (double) $sz->longitude;
$calcDistance = 0 < $lat && 0 < $lng;
if (!$collection) {
$collection = [];
if ($sz) {
$q = str_replace(' ', '%', Inflector::lower(Inflector::unaccent($q)));
$cursor = Model::GeoBano()->where(['sellzone_id', '=', $sz->id])->where(['street', 'LIKE', "%{$q}%"])->cursor();
$c = 0;
while ($row = $cursor->fetch()) {
unset($row['id']);
unset($row['sellzone_id']);
unset($row['created_at']);
unset($row['updated_at']);
$address = $row['street'];
ksort($row);
$distances = distanceKmMiles(floatval($row['lng']), floatval($row['lat']), floatval($lng), floatval($lat));
if ((double) $distances['km'] > 5) {
continue;
}
$old = $row;
if (isset($number)) {
$row = $this->getCoords($first . ' ' . $row['street'] . ' ' . $row['zip'] . ' ' . $row['city']);
} else {
$row = $this->getCoords($row['street'] . ' ' . $row['zip'] . ' ' . $row['city']);
}
if (isset($row['zip'])) {
if (!in_array($row['zip'], $cachedZip)) {
continue;
}
} else {
continue;
}
if (isset($row['city'])) {
if (is_array($row['city'])) {
$row['city_id'] = $row['city']['code'];
$row['city'] = $old['city'];
}
}
$row['address'] = $address;
if ($calcDistance) {
if (isset($row['lng']) && isset($row['lat']) && isset($lat) && isset($lng)) {
$distances = distanceKmMiles(floatval($row['lng']), floatval($row['lat']), floatval($lng), floatval($lat));
$km = floatval($distances['km']);
$row['distance'] = $km;
} else {
$row['distance'] = 0;
}
}
foreach ($row as $k => $v) {
if (fnmatch('*_id', $k)) {
$row[$k] = (int) $v;
} else {
if (is_numeric($v) && (fnmatch('*.*', $v) || fnmatch('*.*', $v))) {
$row[$k] = (double) $v;
}
}
}
if (isset($row['address_label'])) {
$row['name'] = $row['address_label'];
unset($row['address_label']);
}
if (fnmatch($sz->department . '*', $row['zip'])) {
// if (count($collection) >= $limit) {
// return $this->sortBy($collection, 'distance');
// }
$collection[] = $row;
$c++;
}
}
}
redis()->set($keyCache, serialize($collection));
} else {
//.........這裏部分代碼省略.........
示例3: _urlize
private static function _urlize($text)
{
return trim(Inflector::underscore(Inflector::unaccent($text)), '_');
}
示例4: where
public function where($key, $operator = null, $value = null)
{
// Here we will make some assumptions about the operator. If only 2 values are
// passed to the method, we will assume that the operator is an equals sign
// and keep going.
if (func_num_args() == 2) {
list($value, $operator) = [$operator, '='];
}
return $this->filter(function ($item) use($key, $operator, $value) {
$actual = $item->{$key};
$actual = Inflector::lower(Inflector::unaccent($actual));
$value = Inflector::lower(Inflector::unaccent($value));
switch ($operator) {
case '<>':
case '!=':
return sha1($actual) != sha1($value);
break;
case '>':
return $actual > $value;
break;
case '<':
return $actual < $value;
break;
case '>=':
return $actual >= $value;
break;
case '<=':
return $actual <= $value;
break;
case 'between':
return $actual >= $value[0] && $actual <= $value[1];
break;
case 'not between':
return $actual < $value[0] || $actual > $value[1];
break;
case 'in':
return in_array($actual, $value);
break;
case 'not in':
return !in_array($actual, $value);
break;
case 'like':
$value = str_replace("'", '', $value);
$value = str_replace('%', '*', $value);
return fnmatch($value, $actual);
break;
case 'not like':
$value = str_replace("'", '', $value);
$value = str_replace('%', '*', $value);
$check = fnmatch($value, $actual);
return !$check;
break;
case '=':
default:
return sha1($actual) == sha1($value);
break;
}
});
}
示例5: orderSearch
/**
* [orderSearch description]
* @param [type] $collection [description]
* @param [type] $pattern [description]
* @return [type] [description]
*/
private function orderSearch($collection, $pattern)
{
if (empty($collection)) {
return $collection;
}
$newCollection = $lengths = $byItem = [];
foreach ($collection as $item) {
if (!isset($lengths[strlen($item['name'])])) {
$lengths[strlen($item['name'])] = [];
}
$lengths[strlen($item['name'])][] = $item;
}
asort($lengths);
foreach ($lengths as $length => $subColl) {
foreach ($subColl as $k => $segment) {
$comp = Inflector::lower(Inflector::unaccent($pattern));
$value = Inflector::lower(Inflector::unaccent($segment['name']));
$check = fnmatch("{$comp}*", $value);
if ($check) {
$newCollection[] = $segment;
unset($lengths[$length][$k]);
}
}
}
foreach ($lengths as $length => $subColl) {
foreach ($subColl as $k => $segment) {
$newCollection[] = $segment;
}
}
return $newCollection;
}