当前位置: 首页>>代码示例>>PHP>>正文


PHP iconv_strpos函数代码示例

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


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

示例1: testIconvStrPos

 /**
  * @covers Symfony\Polyfill\Iconv\Iconv::iconv_strpos
  * @covers Symfony\Polyfill\Iconv\Iconv::iconv_strrpos
  */
 public function testIconvStrPos()
 {
     $this->assertSame(1, iconv_strpos('11--', '1-', 0, 'UTF-8'));
     $this->assertSame(2, iconv_strpos('-11--', '1-', 0, 'UTF-8'));
     $this->assertSame(false, iconv_strrpos('한국어', '', 'UTF-8'));
     $this->assertSame(1, iconv_strrpos('한국어', '국', 'UTF-8'));
 }
开发者ID:remicollet,项目名称:polyfill,代码行数:11,代码来源:IconvTest.php

示例2: mb_strpos

 /**
  * mb_strpos()
  *
  * WARNING: This function WILL fall-back to strpos()
  * if iconv is not available!
  *
  * @link    http://php.net/mb_strpos()
  * @param    string $haystack
  * @param    string $needle
  * @param    int $offset
  * @param    string $encoding
  * @return    mixed
  */
 function mb_strpos($haystack, $needle, $offset = 0, $encoding = NULL)
 {
     if (ICONV_ENABLED === TRUE) {
         return iconv_strpos($haystack, $needle, $offset, isset($encoding) ? $encoding : config_item('charset'));
     }
     log_message('debug', 'Compatibility (mbstring): iconv_strpos() is not available, falling back to strpos().');
     return strpos($haystack, $needle, $offset);
 }
开发者ID:at15,项目名称:codeignitordb,代码行数:21,代码来源:mbstring.php

示例3: _strpos

 function _strpos($str, $search, $offset = null)
 {
     if (is_null($offset)) {
         $old_enc = $this->_setUTF8IconvEncoding();
         $result = iconv_strpos($str, $search);
         $this->_setIconvEncoding($old_enc);
         return $result;
     } else {
         return iconv_strpos($str, $search, (int) $offset, 'utf-8');
     }
 }
开发者ID:snowjobgit,项目名称:limb,代码行数:11,代码来源:lmbUTF8IconvDriver.class.php

示例4: foo

function foo($haystk, $needle, $offset, $to_charset = false, $from_charset = false)
{
    if ($from_charset !== false) {
        $haystk = iconv($from_charset, $to_charset, $haystk);
    }
    var_dump(strpos($haystk, $needle, $offset));
    if ($to_charset !== false) {
        var_dump(iconv_strpos($haystk, $needle, $offset, $to_charset));
    } else {
        var_dump(iconv_strpos($haystk, $needle, $offset));
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:iconv_strpos.php

示例5: wordWrap

 /**
  * Word wrap
  *
  * @param  string  $string
  * @param  integer $width
  * @param  string  $break
  * @param  boolean $cut
  * @param  string  $charset
  * @return string
  */
 public static function wordWrap($string, $width = 75, $break = "\n", $cut = false, $charset = 'UTF-8')
 {
     $result = array();
     while (($stringLength = iconv_strlen($string, $charset)) > 0) {
         $subString = iconv_substr($string, 0, $width, $charset);
         if ($subString === $string) {
             $cutLength = null;
         } else {
             $nextChar = iconv_substr($string, $width, 1, $charset);
             if ($nextChar === ' ' || $nextChar === $break) {
                 $afterNextChar = iconv_substr($string, $width + 1, 1, $charset);
                 if ($afterNextChar === false) {
                     $subString .= $nextChar;
                 }
                 $cutLength = iconv_strlen($subString, $charset) + 1;
             } else {
                 $spacePos = iconv_strrpos($subString, ' ', $charset);
                 if ($spacePos !== false) {
                     $subString = iconv_substr($subString, 0, $spacePos, $charset);
                     $cutLength = $spacePos + 1;
                 } else {
                     if ($cut === false) {
                         $spacePos = iconv_strpos($string, ' ', 0, $charset);
                         if ($spacePos !== false) {
                             $subString = iconv_substr($string, 0, $spacePos, $charset);
                             $cutLength = $spacePos + 1;
                         } else {
                             $subString = $string;
                             $cutLength = null;
                         }
                     } else {
                         $breakPos = iconv_strpos($subString, $break, 0, $charset);
                         if ($breakPos !== false) {
                             $subString = iconv_substr($subString, 0, $breakPos, $charset);
                             $cutLength = $breakPos + 1;
                         } else {
                             $subString = iconv_substr($subString, 0, $width, $charset);
                             $cutLength = $width;
                         }
                     }
                 }
             }
         }
         $result[] = $subString;
         if ($cutLength !== null) {
             $string = iconv_substr($string, $cutLength, $stringLength - $cutLength, $charset);
         } else {
             break;
         }
     }
     return implode($break, $result);
 }
开发者ID:crlang44,项目名称:frapi,代码行数:62,代码来源:MultiByte.php

示例6: grapheme_position

 protected static function grapheme_position($s, $needle, $offset, $mode)
 {
     if ($offset > 0) {
         $s = (string) self::grapheme_substr($s, $offset);
     } else {
         if ($offset < 0) {
             $offset = 0;
         }
     }
     if ('' === (string) $needle) {
         return false;
     }
     if ('' === (string) $s) {
         return false;
     }
     switch ($mode) {
         case 0:
             $needle = iconv_strpos($s, $needle, 0, 'UTF-8');
             break;
         case 1:
             $needle = mb_stripos($s, $needle, 0, 'UTF-8');
             break;
         case 2:
             $needle = iconv_strrpos($s, $needle, 'UTF-8');
             break;
         default:
             $needle = mb_strripos($s, $needle, 0, 'UTF-8');
             break;
     }
     return $needle ? self::grapheme_strlen(iconv_substr($s, 0, $needle, 'UTF-8')) + $offset : $needle;
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:31,代码来源:Intl.php

示例7: _updateFormat

 /**
  * gets the information required for formating the currency from the LDML files
  * 
  * @return Zend_Currency
  * @throws Zend_Currency_Exception
  */
 protected function _updateFormat()
 {
     $formatLocale = $this->_formatLocale;
     if (empty($formatLocale)) {
         $this->_formatLocale = $this->_currencyLocale;
         $formatLocale = $this->_formatLocale;
     }
     //getting the format information of the currency
     $format = Zend_Locale_Data::getContent($formatLocale, 'currencyformat');
     $format = $format['default'];
     iconv_set_encoding('internal_encoding', 'UTF-8');
     if (iconv_strpos($format, ';')) {
         $format = iconv_substr($format, 0, iconv_strpos($format, ';'));
     }
     //knowing the sign positioning information
     if (iconv_strpos($format, '¤') == 0) {
         $this->_signPosition = self::LEFT;
     } else {
         if (iconv_strpos($format, '¤') == iconv_strlen($format) - 1) {
             $this->_signPosition = self::RIGHT;
         }
     }
     return $this;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:30,代码来源:Currency.php

示例8: appnet_create_entities

function appnet_create_entities($a, $b, $postdata)
{
    require_once "include/bbcode.php";
    require_once "include/plaintext.php";
    $bbcode = $b["body"];
    $bbcode = bb_remove_share_information($bbcode, false, true);
    // Change pure links in text to bbcode uris
    $bbcode = preg_replace("/([^\\]\\='" . '"' . "]|^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
    $URLSearchString = "^\\[\\]";
    $bbcode = preg_replace("/#\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '#$2', $bbcode);
    $bbcode = preg_replace("/@\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '@$2', $bbcode);
    $bbcode = preg_replace("/\\[bookmark\\=([{$URLSearchString}]*)\\](.*?)\\[\\/bookmark\\]/ism", '[url=$1]$2[/url]', $bbcode);
    $bbcode = preg_replace("/\\[video\\](.*?)\\[\\/video\\]/ism", '[url=$1]$1[/url]', $bbcode);
    $bbcode = preg_replace("/\\[youtube\\]https?:\\/\\/(.*?)\\[\\/youtube\\]/ism", '[url=https://$1]https://$1[/url]', $bbcode);
    $bbcode = preg_replace("/\\[youtube\\]([A-Za-z0-9\\-_=]+)(.*?)\\[\\/youtube\\]/ism", '[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode);
    $bbcode = preg_replace("/\\[vimeo\\]https?:\\/\\/(.*?)\\[\\/vimeo\\]/ism", '[url=https://$1]https://$1[/url]', $bbcode);
    $bbcode = preg_replace("/\\[vimeo\\]([0-9]+)(.*?)\\[\\/vimeo\\]/ism", '[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode);
    //$bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode);
    $bbcode = preg_replace("/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism", '[img]$3[/img]', $bbcode);
    preg_match_all("/\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $bbcode, $urls, PREG_SET_ORDER);
    $bbcode = preg_replace("/\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '$1', $bbcode);
    $b["body"] = $bbcode;
    // To-Do:
    // Bilder
    // https://alpha.app.net/heluecht/post/32424376
    // https://alpha.app.net/heluecht/post/32424307
    $plaintext = plaintext($a, $b, 0, false, 6);
    $text = $plaintext["text"];
    $start = 0;
    $entities = array();
    foreach ($urls as $url) {
        $lenurl = iconv_strlen($url[1], "UTF-8");
        $len = iconv_strlen($url[2], "UTF-8");
        $pos = iconv_strpos($text, $url[1], $start, "UTF-8");
        $pre = iconv_substr($text, 0, $pos, "UTF-8");
        $post = iconv_substr($text, $pos + $lenurl, 1000000, "UTF-8");
        $mid = $url[2];
        $html = bbcode($mid, false, false, 6);
        $mid = html2plain($html, 0, true);
        $mid = trim(html_entity_decode($mid, ENT_QUOTES, 'UTF-8'));
        $text = $pre . $mid . $post;
        if ($mid != "") {
            $entities[] = array("pos" => $pos, "len" => $len, "url" => $url[1], "text" => $mid);
        }
        $start = $pos + 1;
    }
    if (isset($postdata["url"]) and isset($postdata["title"]) and $postdata["type"] != "photo") {
        $postdata["title"] = shortenmsg($postdata["title"], 90);
        $max = 256 - strlen($postdata["title"]);
        $text = shortenmsg($text, $max);
        $text .= "\n[" . $postdata["title"] . "](" . $postdata["url"] . ")";
    } elseif (isset($postdata["url"]) and $postdata["type"] != "photo") {
        $postdata["url"] = short_link($postdata["url"]);
        $max = 240;
        $text = shortenmsg($text, $max);
        $text .= " [" . $postdata["url"] . "](" . $postdata["url"] . ")";
    } else {
        $max = 256;
        $text = shortenmsg($text, $max);
    }
    if (iconv_strlen($text, "UTF-8") < $max) {
        $max = iconv_strlen($text, "UTF-8");
    }
    krsort($entities);
    foreach ($entities as $entity) {
        //if (iconv_strlen($text, "UTF-8") >= $entity["pos"] + $entity["len"]) {
        if ($entity["pos"] + $entity["len"] <= $max) {
            $pre = iconv_substr($text, 0, $entity["pos"], "UTF-8");
            $post = iconv_substr($text, $entity["pos"] + $entity["len"], 1000000, "UTF-8");
            $text = $pre . "[" . $entity["text"] . "](" . $entity["url"] . ")" . $post;
        }
    }
    return $text;
}
开发者ID:rabuzarus,项目名称:friendica-addons,代码行数:74,代码来源:appnet.php

示例9: checkDateFormat

 /**
  * Returns if the given datestring contains all date parts from the given format.
  * If no format is given, the default date format from the locale is used
  * If you want to check if the date is a proper date you should use Zend_Date::isDate()
  *
  * @param   string  $date     Date string
  * @param   array   $options  Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details.
  * @return  boolean
  */
 public static function checkDateFormat($date, array $options = array())
 {
     try {
         $date = self::getDate($date, $options);
     } catch (Exception $e) {
         return false;
     }
     if (empty($options['date_format'])) {
         $options['format_type'] = 'iso';
         $options['date_format'] = self::getDateFormat($options['locale']);
     }
     $options = self::_checkOptions($options) + self::$_options;
     // day expected but not parsed
     if (iconv_strpos($options['date_format'], 'd', 0, 'UTF-8') !== false and (!isset($date['day']) or $date['day'] === "")) {
         return false;
     }
     // month expected but not parsed
     if (iconv_strpos($options['date_format'], 'M', 0, 'UTF-8') !== false and (!isset($date['month']) or $date['month'] === "")) {
         return false;
     }
     // year expected but not parsed
     if ((iconv_strpos($options['date_format'], 'Y', 0, 'UTF-8') !== false or iconv_strpos($options['date_format'], 'y', 0, 'UTF-8') !== false) and (!isset($date['year']) or $date['year'] === "")) {
         return false;
     }
     // second expected but not parsed
     if (iconv_strpos($options['date_format'], 's', 0, 'UTF-8') !== false and (!isset($date['second']) or $date['second'] === "")) {
         return false;
     }
     // minute expected but not parsed
     if (iconv_strpos($options['date_format'], 'm', 0, 'UTF-8') !== false and (!isset($date['minute']) or $date['minute'] === "")) {
         return false;
     }
     // hour expected but not parsed
     if ((iconv_strpos($options['date_format'], 'H', 0, 'UTF-8') !== false or iconv_strpos($options['date_format'], 'h', 0, 'UTF-8') !== false) and (!isset($date['hour']) or $date['hour'] === "")) {
         return false;
     }
     return true;
 }
开发者ID:JaroslavRamba,项目名称:ex-facebook-bundle,代码行数:47,代码来源:Format.php

示例10: _updateFormat

 /**
  * Gets the information required for formating the currency from Zend_Locale
  *
  * @return Zend_Currency
  */
 protected function _updateFormat()
 {
     $locale = empty($this->_options['format']) === true ? $this->_locale : $this->_options['format'];
     // Getting the format information of the currency
     $format = Zend_Locale_Data::getContent($locale, 'currencynumber');
     iconv_set_encoding('internal_encoding', 'UTF-8');
     if (iconv_strpos($format, ';') !== false) {
         $format = iconv_substr($format, 0, iconv_strpos($format, ';'));
     }
     // Knowing the sign positioning information
     if (iconv_strpos($format, '¤') === 0) {
         $position = self::LEFT;
     } else {
         if (iconv_strpos($format, '¤') === iconv_strlen($format) - 1) {
             $position = self::RIGHT;
         }
     }
     return $position;
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:24,代码来源:Currency.php

示例11: utf8_strpos

 /**
  * Find position of first occurrence of a string, both arguments are in UTF-8.
  *
  * @param string $haystack UTF-8 string to search in
  * @param string $needle UTF-8 string to search for
  * @param int $offset Position to start the search
  * @return int The character position
  * @see strpos()
  */
 public function utf8_strpos($haystack, $needle, $offset = 0)
 {
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] === 'mbstring') {
         return mb_strpos($haystack, $needle, $offset, 'utf-8');
     } elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] === 'iconv') {
         return iconv_strpos($haystack, $needle, $offset, 'utf-8');
     }
     $byte_offset = $this->utf8_char2byte_pos($haystack, $offset);
     if ($byte_offset === FALSE) {
         // Offset beyond string length
         return FALSE;
     }
     $byte_pos = strpos($haystack, $needle, $byte_offset);
     if ($byte_pos === FALSE) {
         // Needle not found
         return FALSE;
     }
     return $this->utf8_byte2char_pos($haystack, $byte_pos);
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:28,代码来源:CharsetConverter.php

示例12: calculateMeasures

 /**
  * Calculate several measures necessary to generate a bar. 
  * 
  * @return void
  */
 protected function calculateMeasures()
 {
     // Calc number of steps bar goes through
     $this->numSteps = (int) round($this->max / $this->properties['options']->step);
     // Calculate measures
     $this->measures['fixedCharSpace'] = iconv_strlen($this->stripEscapeSequences($this->insertValues()), 'UTF-8');
     if (iconv_strpos($this->properties['options']->formatString, '%max%', 0, 'UTF-8') !== false) {
         $this->measures['maxSpace'] = iconv_strlen(sprintf($this->properties['options']->maxFormat, $this->max), 'UTF-8');
     }
     if (iconv_strpos($this->properties['options']->formatString, '%act%', 0, 'UTF-8') !== false) {
         $this->measures['actSpace'] = iconv_strlen(sprintf($this->properties['options']->actFormat, $this->max), 'UTF-8');
     }
     if (iconv_strpos($this->properties['options']->formatString, '%fraction%', 0, 'UTF-8') !== false) {
         $this->measures['fractionSpace'] = iconv_strlen(sprintf($this->properties['options']->fractionFormat, 100), 'UTF-8');
     }
     $this->measures['barSpace'] = $this->properties['options']->width - array_sum($this->measures);
 }
开发者ID:sakshika,项目名称:ATM,代码行数:22,代码来源:progressbar.php

示例13: divideString

 /**
  * Разбивает строку символом перевода строки на месте проблема наиболее приближенного к центру строки
  * @param string $string
  */
 protected function divideString($string)
 {
     $lastPos = 0;
     $positions = array();
     while (($pos = iconv_strpos($string, ' ', $lastPos, 'UTF-8')) !== false) {
         $positions[abs(iconv_strlen($string, 'UTF-8') - $pos * 2)] = $pos;
         $lastPos = $pos + 1;
     }
     if (count($positions)) {
         ksort($positions);
         $centeredPos = 0;
         foreach ($positions as $pos) {
             $centeredPos = $pos;
             break;
         }
         return iconv_substr($string, 0, $pos, 'UTF-8') . "\n" . iconv_substr($string, $pos + 1, iconv_strlen($string, 'UTF-8'), 'UTF-8');
     }
     return false;
 }
开发者ID:hippout,项目名称:eco-test,代码行数:23,代码来源:Helper.php

示例14: splitInjection

 /**
  * Split string and appending $insert string after $needle
  *
  * @param string $str
  * @param integer $length
  * @param string $needle
  * @param string $insert
  * @return string
  */
 public function splitInjection($str, $length = 50, $needle = '-', $insert = ' ')
 {
     $str = $this->str_split($str, $length);
     $newStr = '';
     foreach ($str as $part) {
         if ($this->strlen($part) >= $length) {
             $lastDelimetr = iconv_strpos(strrev($part), $needle, null, self::ICONV_CHARSET);
             $tmpNewStr = '';
             $tmpNewStr = $this->substr(strrev($part), 0, $lastDelimetr) . $insert . $this->substr(strrev($part), $lastDelimetr);
             $newStr .= strrev($tmpNewStr);
         } else {
             $newStr .= $part;
         }
     }
     return $newStr;
 }
开发者ID:Rinso,项目名称:magento-mirror,代码行数:25,代码来源:String.php

示例15: mb_strpos

 function mb_strpos($haystack, $needle, $offset, $charset = null)
 {
     if (function_exists('iconv_strpos')) {
         return iconv_strpos($haystack, $needle, $offset, $charset);
     } else {
         return strpos($haystack, $needle, $offset);
     }
 }
开发者ID:1Sam,项目名称:rhymix,代码行数:8,代码来源:legacy.php


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