• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP utf8_strpos函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中utf8_strpos函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_strpos函数的具体用法?PHP utf8_strpos怎么用?PHP utf8_strpos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: autoTag

 /**
  * Inserts tag links into an HTML-formatted text.
  *
  * @param string $html
  * @param array $tags
  * @param array $options
  * @return string
  */
 public static function autoTag($html, array $tags, array &$options = array())
 {
     if (empty($tags)) {
         return $html;
     }
     $html = strval($html);
     $htmlNullified = utf8_strtolower($html);
     $htmlNullified = preg_replace_callback('#<a[^>]+>.+?</a>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified);
     $htmlNullified = preg_replace_callback('#<[^>]+>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified);
     // prepare the options
     $onceOnly = empty($options['onceOnly']) ? false : true;
     $options['autoTagged'] = array();
     // reset this
     // sort tags with the longest one first
     // since 1.0.3
     usort($tags, array(__CLASS__, '_autoTag_sortTagsByLength'));
     foreach ($tags as $tag) {
         $offset = 0;
         $tagText = utf8_strtolower($tag['tag']);
         $tagLength = utf8_strlen($tagText);
         while (true) {
             $pos = utf8_strpos($htmlNullified, $tagText, $offset);
             if ($pos !== false) {
                 // the tag has been found
                 if (self::_autoTag_hasValidCharacterAround($html, $pos, $tagText)) {
                     // and it has good surrounding characters
                     // start replacing
                     $displayText = utf8_substr($html, $pos, $tagLength);
                     $template = new XenForo_Template_Public('tinhte_xentag_bb_code_tag_tag');
                     $template->setParam('tag', $tag);
                     $template->setParam('displayText', $displayText);
                     $replacement = $template->render();
                     if (strlen($replacement) === 0) {
                         // in case template system hasn't been initialized
                         $replacement = sprintf('<a href="%s">%s</a>', XenForo_Link::buildPublicLink('tags', $tag), $displayText);
                     }
                     $html = utf8_substr_replace($html, $replacement, $pos, $tagLength);
                     $htmlNullified = utf8_substr_replace($htmlNullified, str_repeat('_', utf8_strlen($replacement)), $pos, $tagLength);
                     // sondh@2012-09-20
                     // keep track of the auto tagged tags
                     $options['autoTagged'][$tagText][$pos] = $replacement;
                     $offset = $pos + utf8_strlen($replacement);
                     if ($onceOnly) {
                         // auto link only once per tag
                         // break the loop now
                         break;
                         // while (true)
                     }
                 } else {
                     $offset = $pos + $tagLength;
                 }
             } else {
                 // no match has been found, stop working with this tag
                 break;
                 // while (true)
             }
         }
     }
     return $html;
 }
开发者ID:maitandat1507,项目名称:Tinhte_XenTag,代码行数:68,代码来源:Integration.php


示例2: utf8_strpos

/**
* UTF-8 aware alternative to strpos
* Find position of first occurrence of a string
* Note: This will get alot slower if offset is used
* Note: requires utf8_strlen amd utf8_substr to be loaded
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer offset in characters (from left)
* @return mixed integer position or FALSE on failure
* @see http://www.php.net/strpos
* @see utf8_strlen
* @see utf8_substr
* @package utf8
* @subpackage strings
*/
function utf8_strpos($str, $needle, $offset = NULL) {
    
    if ( is_null($offset) ) {
    
        $ar = explode($needle, $str);
        if ( count($ar) > 1 ) {
            return utf8_strlen($ar[0]);
        }
        return FALSE;
        
    } else {
        
        if ( !is_int($offset) ) {
            trigger_error('utf8_strpos: Offset must be an integer',E_USER_ERROR);
            return FALSE;
        }
        
        $str = utf8_substr($str, $offset);
        
        if ( FALSE !== ( $pos = utf8_strpos($str, $needle) ) ) {
            return $pos + $offset;
        }
        
        return FALSE;
    }
    
}
开发者ID:joeymetal,项目名称:v1,代码行数:42,代码来源:core.php


示例3: toExternalUrl

 /**
  * @param string $internalUrl
  * @return mixed The URL to access the target file from outside, if available, or FALSE.
  */
 public static function toExternalUrl($internalUrl)
 {
     $currentProc = ProcManager::getInstance()->getCurrentProcess();
     if ($currentProc) {
         $checknum = $currentProc->getChecknum();
     } else {
         $checknum = -1;
     }
     $urlParts = AdvancedPathLib::parse_url($internalUrl);
     if ($urlParts === false) {
         return $internalUrl;
     }
     if ($urlParts['scheme'] === EyeosAbstractVirtualFile::URL_SCHEME_SYSTEM) {
         // EXTERN
         try {
             $externPath = AdvancedPathLib::resolvePath($urlParts['path'], '/extern', AdvancedPathLib::OS_UNIX | AdvancedPathLib::RESOLVEPATH_RETURN_REFDIR_RELATIVE);
             return 'index.php?extern=' . $externPath;
         } catch (Exception $e) {
         }
         // APPS
         try {
             $appPath = AdvancedPathLib::resolvePath($urlParts['path'], '/apps', AdvancedPathLib::OS_UNIX | AdvancedPathLib::RESOLVEPATH_RETURN_REFDIR_RELATIVE);
             $appName = utf8_substr($appPath, 1, utf8_strpos($appPath, '/', 1));
             $appFile = utf8_substr($appPath, utf8_strlen($appName) + 1);
             return 'index.php?checknum=' . $checknum . '&appName=' . $appName . '&appFile=' . $appFile;
         } catch (Exception $e) {
         }
         return $internalUrl;
     }
     //TODO
     return $internalUrl;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:36,代码来源:EyeosUrlTranslator.php


示例4: utf8_strpos

function utf8_strpos($string, $needle, $offset = NULL) {
	if (is_null($offset)) {
		$data = explode($needle, $string, 2);

		if (count($data) > 1) {
			return utf8_strlen($data[0]);
		}

		return false;
	} else {
		if (!is_int($offset)) {
			trigger_error('utf8_strpos: Offset must be an integer', E_USER_ERROR);

			return false;
		}

		$string = utf8_substr($string, $offset);

		if (false !== ($position = utf8_strpos($string, $needle))) {
			return $position + $offset;
		}

		return false;
	}
}
开发者ID:halfhope,项目名称:ocStore,代码行数:25,代码来源:utf8.php


示例5: update

 public static function update($targetClass, $targetPath, $sourceClass, $sourcesContents)
 {
     $targetContents = str_replace($sourceClass, $targetClass, $sourcesContents);
     $php = '<?php';
     $pos = utf8_strpos($targetContents, $php);
     if ($pos !== false) {
         $replacement = sprintf("%s\n\n// updated by %s at %s", $php, __CLASS__, date('c'));
         $targetContents = utf8_substr_replace($targetContents, $replacement, $pos, utf8_strlen($php));
     }
     $classPrefix = substr($targetClass, 0, strpos($targetClass, 'ShippableHelper_'));
     $offset = 0;
     while (true) {
         if (!preg_match('#DevHelper_Helper_ShippableHelper_[a-zA-Z_]+#', $targetContents, $matches, PREG_OFFSET_CAPTURE, $offset)) {
             break;
         }
         $siblingSourceClass = $matches[0][0];
         $offset = $matches[0][1];
         $siblingTargetClass = str_replace('DevHelper_Helper_', $classPrefix, $siblingSourceClass);
         $targetContents = substr_replace($targetContents, $siblingTargetClass, $offset, strlen($siblingSourceClass));
         class_exists($siblingTargetClass);
         $offset += 1;
     }
     $targetContents = preg_replace('#\\* @version \\d+\\s*\\n#', '$0 * @see ' . $sourceClass . "\n", $targetContents, -1, $count);
     return DevHelper_Generator_File::filePutContents($targetPath, $targetContents);
 }
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:25,代码来源:ShippableHelper.php


示例6: render_attributes

 function render_attributes()
 {
     $this->_process_attributes();
     if (!$this->path) {
         $action_path = $_SERVER['PHP_SELF'];
         $request = request::instance();
         if ($node_id = $request->get_attribute('node_id')) {
             $action_path .= '?node_id=' . $node_id;
         }
     } else {
         $action_path = $this->path;
     }
     if (utf8_strpos($action_path, '?') === false) {
         $action_path .= '?';
     } else {
         $action_path .= '&';
     }
     if ($this->action) {
         $action_path .= 'action=' . $this->action;
     }
     if ((bool) $this->reload_parent) {
         $action_path .= '&reload_parent=1';
     }
     $this->attributes['onclick'] = $this->onclick;
     $this->attributes['onclick'] .= "submit_form(this.form, '{$action_path}')";
     parent::render_attributes();
     unset($this->attributes['onclick']);
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:28,代码来源:grid_button_component.class.php


示例7: render_attributes

 function render_attributes()
 {
     if (!isset($this->attributes['path']) || !$this->attributes['path']) {
         $action_path = $_SERVER['PHP_SELF'];
         $request = request::instance();
         if ($node_id = $request->get_attribute('node_id')) {
             $action_path .= '?node_id=' . $node_id;
         }
     } else {
         $action_path = $this->attributes['path'];
     }
     if (utf8_strpos($action_path, '?') === false) {
         $action_path .= '?';
     } else {
         $action_path .= '&';
     }
     if (isset($this->attributes['action'])) {
         $action_path .= 'action=' . $this->attributes['action'];
     }
     if (isset($this->attributes['reload_parent']) && $this->attributes['reload_parent']) {
         $action_path .= '&reload_parent=1';
         unset($this->attributes['reload_parent']);
     }
     if (!isset($this->attributes['onclick'])) {
         $this->attributes['onclick'] = '';
     }
     $this->attributes['onclick'] .= "submit_form(this.form, '{$action_path}')";
     unset($this->attributes['path']);
     unset($this->attributes['action']);
     parent::render_attributes();
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:31,代码来源:control_button_component.class.php


示例8: zula_strpos

/**
 * Unicode: Returns the position of the first occurrence of needle in haystack
 *
 * @param string haystack
 * @param string needle
 * @param int offset
 * @return integer or false on failure
 */
function zula_strpos($haystack, $needle, $offset = null)
{
    if (UNICODE_MBSTRING === true) {
        return $offset === null ? mb_strpos($haystack, $needle) : mb_strpos($haystack, $needle, $offset);
    } else {
        return $offset === null ? utf8_strpos($haystack, $needle) : utf8_strpos($haystack, $needle, $offset);
    }
}
开发者ID:jinshana,项目名称:tangocms,代码行数:16,代码来源:common.php


示例9: _replace_callback

 function _replace_callback($matches)
 {
     if (utf8_strpos($matches[3], '?') === false) {
         $matches[3] .= '?';
     }
     $matches[3] .= '&' . $this->attributes_string;
     return $matches[1] . $matches[2] . $matches[3] . $matches[4];
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:8,代码来源:request_transfer_component.class.php


示例10: strpos_utf

function strpos_utf($haystack, $needle, $offset = 0)
{
    if (function_exists('utf8_strpos')) {
        return utf8_strpos($haystack, $needle, $offset, 'UTF-8');
    } else {
        return strpos($haystack, $needle, $offset);
    }
}
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:8,代码来源:utf.php


示例11: get_matching_phrase

 function get_matching_phrase()
 {
     $phrase = parent::get_matching_phrase();
     if (utf8_strpos($this->uri, 'yandpage') !== false) {
         $phrase = convert_cyr_string(urldecode($phrase), 'k', 'w');
     }
     return $phrase;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:8,代码来源:search_engine_yandex_rule.class.php


示例12: strpos

 /**
  * UTF-8 aware alternative to strpos
  * Find position of first occurrence of a string
  *
  * @static
  * @access public
  * @param $str - string String being examined
  * @param $search - string String being searced for
  * @param $offset - int Optional, specifies the position from which the search should be performed
  * @return mixed Number of characters before the first match or FALSE on failure
  * @see http://www.php.net/strpos
  */
 public static function strpos($str, $search, $offset = FALSE)
 {
     if ($offset === FALSE) {
         return utf8_strpos($str, $search);
     } else {
         return utf8_strpos($str, $search, $offset);
     }
 }
开发者ID:joebushi,项目名称:joomla,代码行数:20,代码来源:string.php


示例13: nel_banned_text

function nel_banned_text($text, $file)
{
    $cancer = array('samefag', '');
    $total_cancer = count($cancer);
    for ($i = 0; $i < $total_cancer; ++$i) {
        if ($cancer[$i] !== '') {
            $test = utf8_strpos($text, $cancer[$i]);
            if ($test !== FALSE) {
                nel_derp(17, array('origin' => 'SNACKS', 'cancer' => $cancer[$i]));
            }
        }
    }
}
开发者ID:OtakuMegane,项目名称:Nelliel,代码行数:13,代码来源:snacks.php


示例14: getRealFile

 /**
  * @param string $path
  * @param SimpleXMLElement $xmlConf
  * @return AbstractFile
  */
 public static function getRealFile($path, $xmlParams = null, $params = null)
 {
     $moutpointDescriptors = MountpointsManager::getInstance()->getMountpointDescriptorsList($path);
     $mountedPath = null;
     $realPath = AdvancedPathLib::getCanonicalURL($path);
     foreach ($moutpointDescriptors as $moutpointDescriptor) {
         $mountpointPath = $moutpointDescriptor->getMountpointPath();
         if (utf8_strpos($realPath, $mountpointPath) === 0) {
             $mountedPath = $moutpointDescriptor->getTargetPath();
             $mountedPath .= '/' . utf8_substr($realPath, utf8_strlen($mountpointPath));
         }
     }
     if ($mountedPath !== null) {
         return FSI::getFile($mountedPath, $params);
     }
     return null;
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:22,代码来源:MountedFileLocator.php


示例15: rdate

 public function rdate($param, $time = 0)
 {
     $this->language->load('record/blog');
     if (intval($time) == 0) {
         $time = time();
     }
     $MonthNames = array($this->language->get('text_january'), $this->language->get('text_february'), $this->language->get('text_march'), $this->language->get('text_april'), $this->language->get('text_may'), $this->language->get('text_june'), $this->language->get('text_july'), $this->language->get('text_august'), $this->language->get('text_september'), $this->language->get('text_october'), $this->language->get('text_november'), $this->language->get('text_december'));
     if (strpos($param, 'M') === false) {
         return date($param, $time);
     } else {
         $str_begin = date(utf8_substr($param, 0, utf8_strpos($param, 'M')), $time);
         $str_middle = $MonthNames[date('n', $time) - 1];
         $str_end = date(utf8_substr($param, utf8_strpos($param, 'M') + 1, utf8_strlen($param)), $time);
         $str_date = $str_begin . $str_middle . $str_end;
         return $str_date;
     }
 }
开发者ID:sasha-adm-in,项目名称:project,代码行数:17,代码来源:search.php


示例16: parse_var_file

/**
* Parses a var file into a data structure. Used in conjunction with an
* Importtag
*/
function parse_var_file($filename)
{
    $result = array();
    $raw_lines = file($filename);
    while (list(, $line) = each($raw_lines)) {
        $equal_pos = utf8_strpos($line, '=');
        if ($equal_pos === false) {
            $result[utf8_trim($line)] = null;
        } else {
            $key = utf8_trim(utf8_substr($line, 0, $equal_pos));
            if (utf8_strlen($key) > 0) {
                $result[$key] = utf8_trim(utf8_substr($line, $equal_pos + 1));
            }
        }
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:21,代码来源:var_file_compiler.inc.php


示例17: getEyeosUserDirectory

 /**
  * @param mixed $user An AbstractEyeosUser object or a username
  */
 public static function getEyeosUserDirectory($user)
 {
     if (!is_dir(USERS_PATH)) {
         mkdir(USERS_PATH, 0777, true);
     }
     $username = $user;
     if ($user instanceof AbstractEyeosUser) {
         $username = $user->getName();
     } else {
         if (!is_string($user)) {
             throw new EyeInvalidArgumentException('$user must be an instance of AbstractEyeosUser or a string.');
         }
     }
     if (utf8_strpos($username, '_') === 0) {
         throw new EyeInvalidArgumentException('System users cannot have directory.');
     }
     return USERS_PATH . '/' . utf8_basename($username);
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:21,代码来源:UMManager.php


示例18: add_url_query_items

function add_url_query_items($url, $items = array())
{
    $str_params = '';
    $request = request::instance();
    if (($node_id = $request->get_attribute('node_id')) && !isset($items['node_id'])) {
        $items['node_id'] = $node_id;
    }
    if (utf8_strpos($url, '?') === false) {
        $url .= '?';
    }
    foreach ($items as $key => $val) {
        $url = preg_replace("/&*{$key}=[^&]*/u", '', $url);
        $str_params .= "&{$key}={$val}";
    }
    $items = utf8_explode('#', $url);
    $url = $items[0];
    $fragment = isset($items[1]) ? '#' . $items[1] : '';
    return $url . $str_params . $fragment;
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:19,代码来源:control_flow.inc.php


示例19: utf8_strpos

/**
* UTF-8 aware alternative to strpos
* Find position of first occurrence of a string
* Note: This will get alot slower if offset is used
* Note: requires utf8_strlen amd utf8_substr to be loaded
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer offset in characters (from left)
* @return mixed integer position or FALSE on failure
* @see http://www.php.net/strpos
* @see utf8_strlen
* @see utf8_substr
* @package utf8
* @subpackage strings
*/
function utf8_strpos($str, $needle, $offset = false)
{
    if ($offset === false) {
        $ar = explode($needle, $str, 2);
        if (count($ar) > 1) {
            return utf8_strlen($ar[0]);
        }
        return false;
    } else {
        if (!is_int($offset)) {
            trigger_error('utf8_strpos: Offset must be an integer', E_USER_ERROR);
            return false;
        }
        $str = utf8_substr($str, $offset);
        if (($pos = utf8_strpos($str, $needle)) !== false) {
            return $pos + $offset;
        }
        return false;
    }
}
开发者ID:HawesDomingue,项目名称:mechanic-watson,代码行数:35,代码来源:core.php


示例20: insertIntoIndex

 /**
  * Inserts or replaces into the index.
  *
  * @see XenForo_Search_SourceHandler_Abstract::insertIntoIndex()
  */
 public function insertIntoIndex($contentType, $contentId, $title, $message, $itemDate, $userId, $discussionId = 0, array $metadata = array())
 {
     if (utf8_strlen($title) > 250) {
         $originalTitle = $title;
         $offset = 250;
         $title = utf8_substr($title, 0, $offset);
         if ($pos = utf8_strpos($title, ' ', $offset - 15)) {
             $title = utf8_substr($title, 0, $pos);
             $offset = $pos;
         }
         $message .= ' ' . utf8_substr($originalTitle, $offset);
         $title = trim($title);
         $message = trim($message);
     }
     $metadataPieces = array($this->getMetadataKey('user', $userId), $this->getMetadataKey('content', $contentType));
     foreach ($metadata as $metadataKey => $value) {
         $piece = $this->getMetadataKey($metadataKey, $value);
         if (is_array($piece)) {
             $metadataPieces = array_merge($metadataPieces, $piece);
         } else {
             $metadataPieces[] = $piece;
         }
     }
     $db = $this->_getDb();
     $row = '(' . $db->quote($contentType) . ', ' . $db->quote(intval($contentId)) . ', ' . $db->quote($title) . ', ' . $db->quote($message) . ', ' . $db->quote(implode(' ', $metadataPieces)) . ', ' . $db->quote(intval($itemDate)) . ', ' . $db->quote(intval($userId)) . ', ' . $db->quote(intval($discussionId)) . ')';
     if ($this->_isRebuild) {
         $this->_bulkInserts[] = $row;
         $this->_bulkInsertLength += strlen($row);
         if ($this->_bulkInsertLength > 500000) {
             $this->_pushToIndex($this->_bulkInserts);
             $this->_bulkInserts = array();
             $this->_bulkInsertLength = 0;
         }
     } else {
         $this->_pushToIndex($row);
     }
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:42,代码来源:MySqlFt.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP utf8_strrev函数代码示例发布时间:2022-05-23
下一篇:
PHP utf8_strlen函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap