本文整理汇总了PHP中utf8_strpos函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_strpos函数的具体用法?PHP utf8_strpos怎么用?PHP utf8_strpos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_strpos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例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']);
}
示例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();
}
示例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);
}
}
示例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];
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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]));
}
}
}
}
示例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;
}
示例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;
}
}