本文整理汇总了PHP中mb_ereg_match函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_ereg_match函数的具体用法?PHP mb_ereg_match怎么用?PHP mb_ereg_match使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_ereg_match函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: addLink
public function addLink($userId, $href, $title, $description, $thumbnailUrl, $text = null, $addToFeed = true)
{
if (!$this->isActive()) {
return null;
}
OW::getCacheManager()->clean(array(LinkDao::CACHE_TAG_LINK_COUNT));
$service = LinkService::getInstance();
$url = mb_ereg_match('^http(s)?:\\/\\/', $href) ? $href : 'http://' . $href;
$link = new Link();
$eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => OW::getUser()->getId());
$privacy = OW::getEventManager()->getInstance()->call('plugin.privacy.get_privacy', $eventParams);
if (!empty($privacy)) {
$link->setPrivacy($privacy);
}
$link->setUserId($userId);
$link->setTimestamp(time());
$link->setUrl($url);
$link->setDescription(strip_tags($description));
$title = empty($title) ? $text : $title;
$link->setTitle(strip_tags($title));
$service->save($link);
if ($addToFeed) {
$content = array("format" => null, "vars" => array("status" => $text));
if (!empty($thumbnailUrl)) {
$content["format"] = "image_content";
$content["vars"]["image"] = $thumbnailUrl;
$content["vars"]["thumbnail"] = $thumbnailUrl;
}
//Newsfeed
$event = new OW_Event('feed.action', array('pluginKey' => 'links', 'entityType' => 'link', 'entityId' => $link->getId(), 'userId' => $link->getUserId()), array("content" => $content));
OW::getEventManager()->trigger($event);
}
return $link->id;
}
开发者ID:vazahat,项目名称:dudex,代码行数:34,代码来源:links_bridge.php
示例3: isValid
public function isValid($value)
{
if (!mb_ereg_match($this->getValidateRegex(), $value)) {
return false;
}
$num_value = $this->getValue($value);
return $this->min <= $num_value && $num_value <= $this->max;
}
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:8,代码来源:Numeric.php
示例4: process
/**
* @inheritdoc
*/
public function process(LanguageInterface $language, $item)
{
$alphabet = implode('', $language->getAlphabet());
$wordPattern = "^[{$alphabet}]+\$";
$options = $this->getOptions();
$itemPassed = mb_ereg_match($wordPattern, $item, $options);
return $itemPassed;
}
开发者ID:kolyunya,项目名称:wiki-parser,代码行数:11,代码来源:AlphabetFilter.php
示例5: searchbooks
public function searchbooks()
{
if ($this->request->is('post')) {
if (empty($this->request->data)) {
$this->redirect('/posts/index');
$this->Session->setFlash('formを入力してください');
}
$title = $this->request->data['Book']['title'];
$author = $this->request->data['Book']['author'];
if (mb_ereg_match("^(\\s| )+\$", $title)) {
if (mb_ereg_match("^(\\s| )+\$", $author)) {
$this->Session->setFlash("ちゃんと入力してください");
$this->redirect('/posts/index');
}
}
$title = preg_replace("/( | )/", "", $title);
$author = preg_replace("/( | )/", "", $author);
if (!empty($title) && !empty($author)) {
$data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'title' => $title, 'author' => $author, 'hits' => 25, 'page' => 1);
} else {
if (!empty($title)) {
$data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'title' => $title, 'hits' => 25, 'page' => 1);
} else {
if (!empty($author)) {
$data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'author' => $author, 'hits' => 25, 'page' => 1);
} else {
$this->Session->setFlash('ちゃんと入力してください');
$this->redirect('/posts/index');
}
}
}
$items = parent::search($data);
if (empty($items)) {
$this->Session->setFlash("該当する本が見つかりませんでした");
$this->redirect('/posts/index');
}
if ($items['count'] == 0) {
$this->Session->setFlash('該当する本が見つかりませんでした');
$this->redirect($this->referer());
}
$count = $items['count'];
$page = $items['page'];
$hits = $items['hits'];
$first = $items['first'];
$tmppage = ceil($count / 25);
$items['count'] = null;
$items['page'] = null;
$items['hits'] = null;
$items['first'] = null;
$this->set('data', $data);
$this->set('items', $items);
$this->set('count', $count);
$this->set('tmppage', $tmppage);
$this->set('page', $page);
$this->set('hits', $hits);
$this->set('first', $first);
}
}
开发者ID:takuyahasegawahterry,项目名称:cakephp,代码行数:58,代码来源:BooksController.php
示例6: setText
public function setText($value)
{
if ($value != '') {
if (!mb_ereg_match(REGEX_STATPIC_TEXT, $value)) {
return false;
}
}
return $this->reUser->setValue('statpic_text', $value);
}
开发者ID:kratenko,项目名称:oc-server3,代码行数:9,代码来源:statpic.class.php
示例7: vxCleanKijijiTitle
public function vxCleanKijijiTitle($title)
{
if (mb_ereg_match('最新的客齐集广告', $title)) {
mb_ereg('最新的客齐集广告 所在地:(.+) 分类:(.+)', $title, $m);
return '最新的客齐集广告' . ' - ' . $m[1] . ' - ' . $m[2];
} else {
return $title;
}
}
开发者ID:biaodianfu,项目名称:project-babel,代码行数:9,代码来源:ChannelCore.php
示例8: processLine
/**
* (non-PHPdoc)
* @see JSONImportStateInterface::processLine()
*/
public function processLine($line)
{
// Change state
if (mb_ereg_match("\"export\"\\:[ ]*\\{.*", $line)) {
return new JSONImportStateMetaData($this->importData);
} else {
return $this;
}
}
开发者ID:iweave,项目名称:unmark,代码行数:13,代码来源:JSONImportStateStart.php
示例9: space_only
function space_only($field = array())
{
foreach ($field as $name => $value) {
}
if (mb_ereg_match("^(\\s| )+\$", $value)) {
return false;
} else {
return true;
}
}
开发者ID:takuyahasegawahterry,项目名称:cakephp,代码行数:10,代码来源:AppModel.php
示例10: checkCaptcha
function checkCaptcha($id, $string)
{
global $CAPTCHA_CONFIG;
$captcha =& new b2evo_captcha($CAPTCHA_CONFIG);
// additional check ... id and string can only contain [a-f0-9]
if (mb_ereg_match('^[0-9a-f]{32}$', $id) == false) {
return false;
}
if ($captcha->validate_submit($id . '.jpg', $string) == 1) {
return true;
} else {
return false;
}
}
开发者ID:RH-Code,项目名称:opencaching,代码行数:14,代码来源:captcha.inc.php
示例11: processLine
/**
* (non-PHPdoc)
* @see JSONImportStateInterface::processLine()
*/
public function processLine($line)
{
// Change state
if (mb_ereg_match("\"marks\"\\:[ ]*\\[.*", $line)) {
return new JSONImportStateMarks($this->importData);
} else {
// Strip trailing comma and simulate JSON
$jsonLine = '{' . mb_ereg_replace("\\,[ ]*\$", '', $line) . '}';
$decodedObject = json_decode($jsonLine);
foreach ($decodedObject as $key => $value) {
if (!isset($this->importData['meta'])) {
$this->importData['meta'] = array();
}
$this->importData['meta'][$key] = $value;
}
return $this;
}
}
开发者ID:iweave,项目名称:unmark,代码行数:22,代码来源:JSONImportStateMetaData.php
示例12: processLine
/**
* (non-PHPdoc)
*
* @see JSONImportStateInterface::processLine()
*/
public function processLine($line)
{
// Finished
if (mb_ereg_match("^[ ]*\\][ ]*\$", $line)) {
return $this->importData;
} else {
// Strip trailing comma and simulate JSON
$jsonLine = mb_ereg_replace("\\,[ ]*\$", '', $line);
$decodedMark = json_decode($jsonLine);
$importResult = $this->CI->mark_import->importMark($decodedMark);
$this->importData['result']['total']++;
$this->importData['result'][$importResult['result']]++;
if (self::RETURN_DETAILS && (!self::RETURN_DETAILS_ERRORS_ONLY || $importResult['result'] === self::RESULT_FAILED || !empty($importResult['warnings']))) {
$this->importData['details'][$decodedMark->mark_id] = $importResult;
}
return $this;
}
}
开发者ID:iweave,项目名称:unmark,代码行数:23,代码来源:JSONImportStateMarks.php
示例13: normalizarNome
/**
* @param string $nome O nome a ser normalizado
* @return string O nome devidamente normalizado
*/
function normalizarNome($nome)
{
$nome = mb_ereg_replace(self::NN_PONTO, self::NN_PONTO_ESPACO, $nome);
$nome = mb_ereg_replace(self::NN_REGEX_MULTIPLOS_ESPACOS, self::NN_ESPACO, $nome);
$nome = ucwords(strtolower($nome));
// alterando essa linha pela anterior funciona para acentos
$partesNome = mb_split(self::NN_ESPACO, $nome);
$excecoes = array('de', 'do', 'di', 'da', 'dos', 'das', 'dello', 'della', 'dalla', 'dal', 'del', 'e', 'em', 'na', 'no', 'nas', 'nos', 'van', 'von', 'y', 'der');
for ($i = 0; $i < count($partesNome); ++$i) {
if (mb_ereg_match(self::NN_REGEX_NUMERO_ROMANO, mb_strtoupper($partesNome[$i]))) {
$partesNome[$i] = mb_strtoupper($partesNome[$i]);
}
foreach ($excecoes as $excecao) {
if (mb_strtolower($partesNome[$i]) == mb_strtolower($excecao)) {
$partesNome[$i] = $excecao;
}
}
}
$nomeCompleto = implode(self::NN_ESPACO, $partesNome);
return addslashes($nomeCompleto);
}
开发者ID:CGPUCPR,项目名称:SwB-2nd,代码行数:25,代码来源:form_sisdoc_helper.php
示例14: filter
/**
* Enter description here...
*
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
* @link http://docs.jquery.com/Traversing/filter
*/
public function filter($selectors, $_skipHistory = false)
{
if ($selectors instanceof Callback or $selectors instanceof Closure) {
return $this->filterCallback($selectors, $_skipHistory);
}
if (!$_skipHistory) {
$this->elementsBackup = $this->elements;
}
$notSimpleSelector = array(' ', '>', '~', '+', '/');
if (!is_array($selectors)) {
$selectors = $this->parseSelector($selectors);
}
if (!$_skipHistory) {
$this->debug(array("Filtering:", $selectors));
}
$finalStack = array();
foreach ($selectors as $selector) {
$stack = array();
if (!$selector) {
break;
}
// avoid first space or /
if (in_array($selector[0], $notSimpleSelector)) {
$selector = array_slice($selector, 1);
}
// PER NODE selector chunks
foreach ($this->stack() as $node) {
$break = false;
foreach ($selector as $s) {
if (!$node instanceof DOMELEMENT) {
// all besides DOMElement
if ($s[0] == '[') {
$attr = trim($s, '[]');
if (mb_strpos($attr, '=')) {
list($attr, $val) = explode('=', $attr);
if ($attr == 'nodeType' && $node->nodeType != $val) {
$break = true;
}
}
} else {
$break = true;
}
} else {
// DOMElement only
// ID
if ($s[0] == '#') {
if ($node->getAttribute('id') != substr($s, 1)) {
$break = true;
}
// CLASSES
} else {
if ($s[0] == '.') {
if (!$this->matchClasses($s, $node)) {
$break = true;
}
// ATTRS
} else {
if ($s[0] == '[') {
// strip side brackets
$attr = trim($s, '[]');
if (mb_strpos($attr, '=')) {
list($attr, $val) = explode('=', $attr);
$val = self::unQuote($val);
if ($attr == 'nodeType') {
if ($val != $node->nodeType) {
$break = true;
}
} else {
if ($this->isRegexp($attr)) {
$val = extension_loaded('mbstring') && phpQuery::$mbstringSupport ? quotemeta(trim($val, '"\'')) : preg_quote(trim($val, '"\''), '@');
// switch last character
switch (substr($attr, -1)) {
// quotemeta used insted of preg_quote
// http://code.google.com/p/phpquery/issues/detail?id=76
case '^':
$pattern = '^' . $val;
break;
case '*':
$pattern = '.*' . $val . '.*';
break;
case '$':
$pattern = '.*' . $val . '$';
break;
}
// cut last character
$attr = substr($attr, 0, -1);
$isMatch = extension_loaded('mbstring') && phpQuery::$mbstringSupport ? mb_ereg_match($pattern, $node->getAttribute($attr)) : preg_match("@{$pattern}@", $node->getAttribute($attr));
if (!$isMatch) {
$break = true;
}
} else {
if ($node->getAttribute($attr) != $val) {
$break = true;
}
//.........这里部分代码省略.........
开发者ID:limi58,项目名称:fetchJD,代码行数:101,代码来源:phpQueryObject.php
示例15: requestHandler
private function requestHandler($query, $types)
{
$result = array('msg' => JText::_('PED_CITY_COUNTRY_NOT_FOUND'));
// Инициализация структуры массива ответа
foreach ($types as $t) {
$result[$t] = array('length' => 0);
}
// Подготовка строк для поиска
$query = mb_strtolower($query, 'utf-8');
mb_regex_encoding('utf-8');
$qList = mb_split("[^\\w]", $query);
// Отбрасывание слов менее 3х букв
foreach ($qList as $k => $query) {
if (mb_strlen($query, 'utf-8') < 3) {
unset($qList[$k]);
}
}
// Проверка налиция шаблонов для поиска
if (!count($qList)) {
$result['msg'] = JText::_('PED_SMALL_QUERY');
return $result;
}
// Получение списка городов/стран
$list = $this->getDestinations();
// Обрбаотка каждого типа поля
foreach ($types as &$type) {
// Поиск совпадений по списку городов/стран
// и заполнение массива с результатами
foreach ($list[$type] as $k => &$v) {
// Поиск совпадений для каждой части запроса
foreach ($qList as &$q) {
if (mb_ereg_match(".*\\b" . $q . ".*", mb_strtolower($v, 'utf-8'))) {
$result[$type][$k] = $v;
}
}
}
// Сортировка результатов и удаление дубликатов
$result[$type] = array_unique($result[$type]);
asort($result[$type]);
$result[$type]['length'] = count($result[$type]) - 1;
}
return $result;
}
开发者ID:arkane0906,项目名称:lasercut-bootstrap,代码行数:43,代码来源:edost.php
示例16: validate_coords
function validate_coords($lat_h, $lat_min, $lon_h, $lon_min, $lonEW, $latNS, $error_coords_not_ok)
{
if ($lat_h == '') {
tpl_set_var('lat_message', $error_coords_not_ok);
$error = true;
}
if ($lat_min == '') {
tpl_set_var('lat_message', $error_coords_not_ok);
$error = true;
}
if ($lon_h == '') {
tpl_set_var('lon_message', $error_coords_not_ok);
$error = true;
}
if ($lon_min == '') {
tpl_set_var('lon_message', $error_coords_not_ok);
$error = true;
}
if (@$error) {
return $error;
}
//check coordinates
$error = false;
if ($lat_h != '' || $lat_min != '') {
if (!mb_ereg_match('^[0-9]{1,2}$', $lat_h)) {
tpl_set_var('lat_message', $error_coords_not_ok);
$error = true;
$lat_h_not_ok = true;
} else {
if ($lat_h >= 0 && $lat_h < 90) {
$lat_h_not_ok = false;
} else {
tpl_set_var('lat_message', $error_coords_not_ok);
$error = true;
$lat_h_not_ok = true;
}
}
if (is_numeric($lat_min)) {
if ($lat_min >= 0 && $lat_min < 60) {
$lat_min_not_ok = false;
} else {
tpl_set_var('lat_message', $error_coords_not_ok);
$error = true;
$lat_min_not_ok = true;
}
} else {
tpl_set_var('lat_message', $error_coords_not_ok);
$error = true;
$lat_min_not_ok = true;
}
$latitude = $lat_h + round($lat_min, 3) / 60;
if ($latNS == 'S') {
$latitude = -$latitude;
}
if ($latitude == 0) {
tpl_set_var('lon_message', $error_coords_not_ok);
$error = true;
$lat_min_not_ok = true;
}
} else {
$latitude = NULL;
$lat_h_not_ok = true;
$lat_min_not_ok = true;
$error = true;
}
if ($lon_h != '' || $lon_min != '') {
if (!mb_ereg_match('^[0-9]{1,3}$', $lon_h)) {
tpl_set_var('lon_message', $error_coords_not_ok);
$error = true;
$lon_h_not_ok = true;
} else {
if ($lon_h >= 0 && $lon_h < 180) {
$lon_h_not_ok = false;
} else {
tpl_set_var('lon_message', $error_coords_not_ok);
$error = true;
$lon_h_not_ok = true;
}
}
if (is_numeric($lon_min)) {
if ($lon_min >= 0 && $lon_min < 60) {
$lon_min_not_ok = false;
} else {
tpl_set_var('lon_message', $error_coords_not_ok);
$error = true;
$lon_min_not_ok = true;
}
} else {
tpl_set_var('lon_message', $error_coords_not_ok);
$error = true;
$lon_min_not_ok = true;
}
$longitude = $lon_h + round($lon_min, 3) / 60;
if ($lonEW == 'W') {
$longitude = -$longitude;
}
if ($longitude == 0) {
tpl_set_var('lon_message', $error_coords_not_ok);
$error = true;
$lon_min_not_ok = true;
//.........这里部分代码省略.........
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:101,代码来源:log.php
示例17: drawRows
/** drawRows
* Draws out a defined set of rows from the sheet.
* @param $sheet The data container.
* @param $begin The index of the begining row. (included)
* @param $end The index of the end row (excluded)
*/
function drawRows(TikiSheet &$sheet)
{
$sheetlib = TikiLib::lib('sheet');
$beginRow = $sheet->getRangeBeginRow();
$endRow = $sheet->getRangeEndRow();
$beginCol = $sheet->getRangeBeginCol();
$endCol = $sheet->getRangeEndCol();
for ($i = $beginRow; $i < $endRow; $i++) {
$td = "";
$trStyleHeight = "";
$trHeight = "20px";
$trHeightIsSet = false;
for ($j = $beginCol; $j < $endCol; $j++) {
$width = $height = '';
if (!empty($sheet->cellInfo[$i][$j])) {
extract($sheet->cellInfo[$i][$j]);
}
$append = '';
if ($width > 1) {
$append .= " colspan='{$width}'";
}
if ($height > 1) {
$append .= " rowspan='{$height}'";
}
if (!empty($sheet->calcGrid[$i][$j])) {
$append .= ' data-formula="=' . str_replace('"', "'", $sheet->calcGrid[$i][$j]['calculation']) . '"';
}
if (isset($sheet->dataGrid[$i][$j]['value'])) {
$data = $sheet->dataGrid[$i][$j]['value'];
} else {
$data = '';
}
$format = $sheet->cellInfo[$i][$j]['format'];
if (!empty($format)) {
$data = TikiSheetDataFormat::$format($data);
}
$style = $sheet->cellInfo[$i][$j]['style'];
if (!empty($style)) {
//we have to sanitize the css style here
$tdStyle = "";
$color = $sheetlib->get_attr_from_css_string($style, "color", "");
$bgColor = $sheetlib->get_attr_from_css_string($style, "background-color", "");
$tdHeight = '';
if ($trHeightIsSet == false) {
$trHeight = $sheetlib->get_attr_from_css_string($style, "height", "20px");
$trHeightIsSet = true;
}
if ($color) {
$tdStyle .= "color:{$color};";
}
if ($bgColor) {
$tdStyle .= "background-color:{$bgColor};";
}
$tdHeight = $trHeight;
if ($tdHeight) {
$tdStyle .= "height:{$tdHeight};";
$append .= " height='" . str_replace("px", "", $tdHeight) . "'";
}
$append .= " style='{$tdStyle}'";
}
$class = $sheet->cellInfo[$i][$j]['class'];
if (!empty($class)) {
$append .= ' class="' . $class . '"';
}
if ($this->parseOutput && $sheet->parseValues == 'y') {
global $tikilib;
// only parse if we have non-alphanumeric or space chars
if (mb_ereg_match('[^A-Za-z0-9\\s]', $data)) {
// needs to be multibyte regex here
$data = $tikilib->parse_data($data, array('suppress_icons' => true));
}
if (strpos($data, '<p>') === 0) {
// remove containing <p> tag
$data = substr($data, 3);
if (strrpos($data, '</p>') === strlen($data) - 4) {
$data = substr($data, 0, -4);
}
}
}
$td .= "\t\t\t<td" . $append . ">{$data}</td>\n";
}
if (!empty($td)) {
$this->output .= "\t\t<tr style='height: {$trHeight};' height='" . str_replace("px", "", $trHeight) . "'>\n";
$this->output .= $td;
$this->output .= "\t\t</tr>\n";
}
}
}
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:94,代码来源:grid.php
示例18: matchesPattern
/**
* Returns true if $str matches the supplied pattern, false otherwise.
*
* @param string $pattern Regex pattern to match against
* @return bool Whether or not $str matches the pattern
*/
private function matchesPattern($pattern)
{
$regexEncoding = mb_regex_encoding();
mb_regex_encoding($this->encoding);
$match = mb_ereg_match($pattern, $this->str);
mb_regex_encoding($regexEncoding);
return $match;
}
开发者ID:kemerov4anin,项目名称:wachanga,代码行数:14,代码来源:Stringy.php
示例19: isAlpha
/**
* Returns true if the every character in the parameter is an alphabetic
* character.
*
* @param string $string The string to test.
* @param string $charset The charset to use when testing the string.
*
* @return boolean True if the parameter was alphabetic only.
*/
public static function isAlpha($string, $charset)
{
if (!Horde_Util::extensionExists('mbstring')) {
return ctype_alpha($string);
}
$charset = self::_mbstringCharset($charset);
$old_charset = mb_regex_encoding();
if ($charset != $old_charset) {
@mb_regex_encoding($charset);
}
$alpha = !@mb_ereg_match('[^[:alpha:]]', $string);
if ($charset != $old_charset) {
@mb_regex_encoding($old_charset);
}
return $alpha;
}
开发者ID:raz0rsdge,项目名称:horde,代码行数:25,代码来源:String.php
示例20: getSqlDistanceFormula
static function getSqlDistanceFormula($lonFrom, $latFrom, $maxDistance, $distanceMultiplier = 1, $lonField = 'longitude', $latField = 'latitude', $tableName = 'caches')
{
$lonFrom = $lonFrom + 0;
$latFrom = $latFrom + 0;
$maxDistance = $maxDistance + 0;
$distanceMultiplier = $distanceMultiplier + 0;
if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $lonField)) {
die('Fatal Error: invalid lonField');
}
if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $latField)) {
die('Fatal Error: invalid latField');
}
if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $tableName)) {
die('Fatal Error: invalid tableName');
}
$b1_rad = sprintf('%01.5f', (90 - $latFrom) * 3.14159 / 180);
$l1_deg = sprintf('%01.5f', $lonFrom);
$lonField = '`' . sql_escape_backtick($tableName) . '`.`' . sql_escape_backtick($lonField) . '`';
$latField = '`' . sql_escape_backtick($tableName) . '`.`' . sql_escape_backtick($latField) . '`';
$r = 6370 * $distanceMultiplier;
$retval = 'acos(cos(' . $b1_rad . ') * cos((90-' . $latField . ') * 3.14159 / 180) + sin(' . $b1_rad . ') * sin((90-' . $latField . ') * 3.14159 / 180) * cos((' . $l1_deg . '-' . $lonField . ') * 3.14159 / 180)) * ' . $r;
return $retval;
}
开发者ID:RH-Code,项目名称:opencaching,代码行数:23,代码来源:geomath.class.php
注:本文中的mb_ereg_match函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论