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

PHP iconv_strpos函数代码示例

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

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



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


示例16: mb_strpos

 function mb_strpos($haystack, $needle, $offset = 0, $encoding = '')
 {
     $encoding = $this->regularize_encoding($encoding);
     if ($this->use_iconv) {
         return iconv_strpos($haystack, $needle, $offset, $encoding);
     } else {
         switch ($e = $this->mbemu_internals['encoding'][$encoding]) {
             case 1:
                 //euc-jp
             //euc-jp
             case 2:
                 //shift-jis
             //shift-jis
             case 4:
                 //utf-8
             //utf-8
             case 5:
                 //utf-16
             //utf-16
             case 8:
                 //utf16BE
                 preg_match_all('/' . $this->mbemu_internals['regex'][$e] . '/', $haystack, $ar_h);
                 preg_match_all('/' . $this->mbemu_internals['regex'][$e] . '/', $needle, $ar_n);
                 return $this->_sub_strpos($ar_h[0], $ar_n[0], $offset);
             case 3:
                 //jis
                 $haystack = $this->mb_convert_encoding($haystack, 'SJIS', 'JIS');
                 $needle = $this->mb_convert_encoding($needle, 'SJIS', 'JIS');
                 preg_match_all('/' . $this->mbemu_internals['regex'][2] . '/', $haystack, $ar_h);
                 preg_match_all('/' . $this->mbemu_internals['regex'][2] . '/', $needle, $ar_n);
                 return $this->_sub_strpos($ar_h[0], $ar_n[0], $offset);
             case 0:
                 //ascii
             //ascii
             case 6:
                 //iso-8859-1
             //iso-8859-1
             default:
                 return strpos($haystack, $needle, $offset);
         }
     }
 }
开发者ID:nao-pon,项目名称:HypCommon,代码行数:42,代码来源:mb-emulator.php


示例17: unset

//get an unset variable
$unset_var = 10;
unset($unset_var);
// get a class
class classA
{
    public function __toString()
    {
        return "UTF-8";
    }
}
// heredoc string
$heredoc = <<<EOT
UTF-8
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// unexpected values to be passed to $input argument
$inputs = array(0, 1, 12345, -2345, 10.5, -10.5, 123456789000.0, 1.23456789E-9, 0.5, NULL, null, true, false, TRUE, FALSE, "", '', "UTF-8", 'UTF-8', $heredoc, new classA(), @$undefined_var, @$unset_var, $fp);
// loop through each element of $inputs to check the behavior of iconv_strpos()
$iterator = 1;
foreach ($inputs as $input) {
    echo "\n-- Iteration {$iterator} --\n";
    var_dump(iconv_strpos($haystack, $needle, $offset, $input));
    $iterator++;
}
fclose($fp);
echo "Done";
?>

开发者ID:badlamer,项目名称:hhvm,代码行数:29,代码来源:iconv_strpos_variation4.php


示例18: utf8_strpos

 function utf8_strpos($string, $needle, $offset = 0)
 {
     return iconv_strpos($string, $needle, $offset, 'UTF-8');
 }
开发者ID:valentinemwangi,项目名称:EcommerceWebsite-DrinksOnWheels,代码行数:4,代码来源:utf8.php


示例19: api_get_entitities

function api_get_entitities(&$text, $bbcode)
{
    /*
    To-Do:
    * Links at the first character of the post
    */
    $a = get_app();
    $include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false");
    if ($include_entities != "true") {
        preg_match_all("/\\[img](.*?)\\[\\/img\\]/ism", $bbcode, $images);
        foreach ($images[1] as $image) {
            $replace = proxy_url($image);
            $text = str_replace($image, $replace, $text);
        }
        return array();
    }
    $bbcode = bb_CleanPictureLinks($bbcode);
    // Change pure links in text to bbcode uris
    $bbcode = preg_replace("/([^\\]\\='" . '"' . "]|^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
    $entities = array();
    $entities["hashtags"] = array();
    $entities["symbols"] = array();
    $entities["urls"] = array();
    $entities["user_mentions"] = array();
    $URLSearchString = "^\\[\\]";
    $bbcode = preg_replace("/#\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '#$2', $bbcode);
    $bbcode = preg_replace("/\\[bookmark\\=([{$URLSearchString}]*)\\](.*?)\\[\\/bookmark\\]/ism", '[url=$1]$2[/url]', $bbcode);
    //$bbcode = preg_replace("/\[url\](.*?)\[\/url\]/ism",'[url=$1]$1[/url]',$bbcode);
    $bbcode = preg_replace("/\\[video\\](.*?)\\[\\/video\\]/ism", '[url=$1]$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("/\\[youtube\\](.*?)\\[\\/youtube\\]/ism", '[url=$1]$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, $urls1);
    preg_match_all("/\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $bbcode, $urls);
    $ordered_urls = array();
    foreach ($urls[1] as $id => $url) {
        //$start = strpos($text, $url, $offset);
        $start = iconv_strpos($text, $url, 0, "UTF-8");
        if (!($start === false)) {
            $ordered_urls[$start] = array("url" => $url, "title" => $urls[2][$id]);
        }
    }
    ksort($ordered_urls);
    $offset = 0;
    //foreach ($urls[1] AS $id=>$url) {
    foreach ($ordered_urls as $url) {
        if (substr($url["title"], 0, 7) != "http://" and substr($url["title"], 0, 8) != "https://" and !strpos($url["title"], "http://") and !strpos($url["title"], "https://")) {
            $display_url = $url["title"];
        } else {
            $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url["url"]);
            $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);
            if (strlen($display_url) > 26) {
                $display_url = substr($display_url, 0, 25) . "…";
            }
        }
        //$start = strpos($text, $url, $offset);
        $start = iconv_strpos($text, $url["url"], $offset, "UTF-8");
        if (!($start === false)) {
            $entities["urls"][] = array("url" => $url["url"], "expanded_url" => $url["url"], "display_url" => $display_url, "indices" => array($start, $start + strlen($url["url"])));
            $offset = $start + 1;
        }
    }
    preg_match_all("/\\[img](.*?)\\[\\/img\\]/ism", $bbcode, $images);
    $ordered_images = array();
    foreach ($images[1] as $image) {
        //$start = strpos($text, $url, $offset);
        $start = iconv_strpos($text, $image, 0, "UTF-8");
        if (!($start === false)) {
            $ordered_images[$start] = $image;
        }
    }
    //$entities["media"] = array();
    $offset = 0;
    foreach ($ordered_images as $url) {
        $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url);
        $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);
        if (strlen($display_url) > 26) {
            $display_url = substr($display_url, 0, 25) . "…";
        }
        $start = iconv_strpos($text, $url, $offset, "UTF-8");
        if (!($start === false)) {
            $image = get_photo_info($url);
            if ($image) {
                // If image cache is activated, then use the following sizes:
                // thumb  (150), small (340), medium (600) and large (1024)
                if (!get_config("system", "proxy_disabled")) {
                    $media_url = proxy_url($url);
                    $sizes = array();
                    $scale = scale_image($image[0], $image[1], 150);
                    $sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
                    if ($image[0] > 150 or $image[1] > 150) {
                        $scale = scale_image($image[0], $image[1], 340);
                        $sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
                    }
                    $scale = scale_image($image[0], $image[1], 600);
                    $sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
                    if ($image[0] > 600 or $image[1] > 600) {
                        $scale = scale_image($image[0], $image[1], 1024);
//.........这里部分代码省略.........
开发者ID:ZerGabriel,项目名称:friendica,代码行数:101,代码来源:api.php


示例20: _parseBB

 protected function _parseBB($text_forum, $id = 0, $type = 'pm')
 {
     $this->_init_parse();
     if ($type == 'post' && iconv_strpos($text_forum, "[attachment=", 0, DLE_CHARSET) !== false) {
         $this->_db_disconnect();
         $this->db->query("SELECT id, name, onserver, dcount FROM " . PREFIX . "_files WHERE news_id={$id}");
         while ($file = $this->db->get_row()) {
             preg_match("#\\[attachment={$file['id']}:(.+?)\\]#i", $text_forum, $matche);
             $size = formatsize(@filesize(ROOT_DIR . '/uploads/files/' . $file['onserver']));
             $file['name'] = explode("/", $file['name']);
             $file['name'] = end($file['name']);
             if (!empty($matche)) {
                 $file['name'] = $matche[1];
             }
             if ($GLOBALS['config']['files_count'] == 'yes') {
                 $link = "[URL=\"{$GLOBALS['config']['http_home_url']}engine/download.php?id={$file['id']}\"]{$file['name']}[/URL] [{$size}] ({$this->lang['att_dcount']} {$file['dcount']})";
             } else {
                 $link = "[URL=\"{$GLOBALS['config']['http_home_url']}engine/download.php?id={$file['id']}\"]{$file['name']}[/URL] [{$size}]";
             }
             $text_forum = preg_replace("#\\[attachment={$file['id']}(:.+?)?\\]#i", $link, $text_forum);
         }
         $this->_db_connect();
     }
     if ($type == 'post') {
         $text_forum = preg_replace('#\\[[^U]+\\]#i', '', $text_forum);
         $text_forum = $this->_parse->decodeBBCodes($text_forum, false);
         $text_forum = preg_replace('#\\[page=[0-9]+\\]#si', "", $text_forum);
         $text_forum = str_replace('{PAGEBREAK}', '', $text_forum);
         $text_forum = preg_replace('#\\[hide\\](.*?)\\[/hide\\]#si', "\\1", $text_forum);
     }
     $text_forum = html_entity_decode($text_forum);
     $text_forum = preg_replace('#\\[s\\](.*?)\\[/s\\]#si', "\\1", $text_forum);
     //$text_forum = preg_replace('#\[spoiler(=.+?)?\](.*?)\[/spoiler\]#si', "\\2", $text_forum);
     $text_forum = preg_replace('#\\[img=(.+?)\\](.*?)\\[/img\\]#si', "[\\1][img]\\2[/img][/\\1]", $text_forum);
     /*$text_forum = preg_replace('#<.+?>#s', '', $text_forum);*/
     $smilies_arr = explode(",", $GLOBALS['config']['smilies']);
     foreach ($smilies_arr as $smile) {
         $smile = trim($smile);
         $find[] = "#:{$smile}:#si";
         $replace[] = "[img]" . $GLOBALS['config']['http_home_url'] . "engine/data/emoticons/{$smile}.gif[/img]";
     }
     $text_forum = preg_replace($find, $replace, $text_forum);
     $text_forum = str_replace('leech', 'url', $text_forum);
     if ($type == 'post') {
         $text_forum = preg_replace("#\\[video\\s*=\\s*(\\S.+?)\\s*\\]#ie", "\$this->_parse->build_video('\\1')", $text_forum);
         $text_forum = preg_replace("#\\[audio\\s*=\\s*(\\S.+?)\\s*\\]#ie", "\$this->_parse->build_audio('\\1')", $text_forum);
         $text_forum = preg_replace("#\\[flash=([^\\]]+)\\](.+?)\\[/flash\\]#ies", "\$this->_parse->build_flash('\\1', '\\2')", $text_forum);
         $text_forum = preg_replace("#\\[youtube=([^\\]]+)\\]#ies", "\$this->_parse->build_youtube('\\1')", $text_forum);
         $text_forum = preg_replace("'\\[thumb\\]([^\\[]*)([/\\\\])(.*?)\\[/thumb\\]'ie", "\$this->build_thumb('\$1\$2\$3', '\$1\$2thumbs\$2\$3')", $text_forum);
         $text_forum = preg_replace("'\\[thumb=(.*?)\\]([^\\[]*)([/\\\\])(.*?)\\[/thumb\\]'ie", "\$this->build_thumb('\$2\$3\$4', '\$2\$3thumbs\$3\$4', '\$1')", $text_forum);
         $text_forum = str_replace('D27CDB6E', 'F27CDB6E', $text_forum);
         preg_match_all('#<object .+?</object>#si', $text_forum, $mathes);
         if (!empty($mathes[0])) {
             foreach ($mathes[0] as $obj) {
                 $obj_new = str_replace("\n", '', $obj);
                 $obj_new = str_replace("\r", '', $obj_new);
                 $obj_new = str_replace("\t", '', $obj_new);
                 $obj_new = preg_replace('# {2,}#si', " ", $obj_new);
                 $text_forum = str_replace($obj, $obj_new, $text_forum);
                 $text_forum = urldecode($text_forum);
             }
         }
     }
     $text_forum = preg_replace('#<!--.+?-->#s', '', $text_forum);
     $text_forum = str_replace('{THEME}', $GLOBALS['config']['http_home_url'] . 'templates/' . $GLOBALS['config']['skin'], $text_forum);
     return $text_forum;
 }
开发者ID:dautushenka,项目名称:dle-vb,代码行数:67,代码来源:dle_vs_vb.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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