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


PHP JString::str_split方法代码示例

本文整理汇总了PHP中JString::str_split方法的典型用法代码示例。如果您正苦于以下问题:PHP JString::str_split方法的具体用法?PHP JString::str_split怎么用?PHP JString::str_split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JString的用法示例。


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

示例1: safe

 /**
  * Safe String. Remove no letter's, no number's and other's no allowed Signs.
  *
  * @param string $string String to safe
  * @return string
  */
 public static function safe($string)
 {
     static $items;
     if (is_null($items)) {
         $letters[] = 'abcdefghijklmnopqrstuvwxyz';
         $letters[] = 'áćéǵíḱĺḿńóṕŕśúǘẃýź';
         $letters[] = 'äëḧïöẗüẅẍÿ';
         $letters[] = 'åůẘẙ';
         $letters[] = 'ǎčďěǧȟǐǰǩľňǒřšťǔǚž';
         $letters[] = '.-_ ';
         $items = array();
         foreach ($letters as $item) {
             $items = array_merge($items, parent::str_split($item), parent::str_split(parent::strtoupper($item)));
         }
         $items = array_merge($items, parent::str_split('0123456789'));
     }
     $string = parent::str_split($string);
     $safe = '';
     foreach ($string as $item) {
         if (in_array($item, $items)) {
             $safe .= $item;
         }
     }
     return parent::trim($safe);
 }
开发者ID:abdullah929,项目名称:bulletin,代码行数:31,代码来源:string.php

示例2: translate

 /**
  * Translate a long text by Google, if it too long, will separate it..
  *
  * @param   string  $text      String to translate.
  * @param   string  $SourceLan Translate from this language, eg: 'zh-tw'. Empty will auto detect.
  * @param   string  $ResultLan Translate to this language, eg: 'en'. Empty will auto detect.
  * @param   integer $separate  Separate text by a number of words, batch translate them and re combine to return.
  *
  * @return  string    Translated text.
  */
 public static function translate($text, $SourceLan = null, $ResultLan = null, $separate = 0)
 {
     // If text too big, separate it.
     if ($separate) {
         if (\JString::strlen($text) > $separate) {
             $text = \JString::str_split($text, $separate);
         } else {
             $text = array($text);
         }
     } else {
         $text = array($text);
     }
     $result = '';
     // Do translate by google translate API.
     foreach ($text as $txt) {
         $result .= self::gTranslate($txt, $SourceLan, $ResultLan);
     }
     return $result;
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:29,代码来源:LanguageHelper.php

示例3: testStr_split

 /**
  * @group String
  * @covers JString::str_split
  * @dataProvider str_splitData
  */
 public function testStr_split($string, $split_length, $expect)
 {
     $actual = JString::str_split($string, $split_length);
     $this->assertEquals($expect, $actual);
 }
开发者ID:GMaup,项目名称:joomla-platform,代码行数:10,代码来源:JStringTest.php

示例4: censureWords

 /**
  * Parse the content by censoring blacklisted words.
  * Borrowed from php-decoda.
  *
  * @param	string	$content
  * @return	string
  */
 public function censureWords($content)
 {
     $censored = $this->params->get('censored_words', '');
     $censored = array_filter(array_map(array('JString', 'trim'), explode(',', $censored)));
     foreach ($censored as $word) {
         $letters = JString::str_split($word);
         $regex = '';
         foreach ($letters as $letter) {
             $regex .= preg_quote($letter, '/') . '{1,}';
         }
         $content = preg_replace_callback('/(^|\\s|\\n)?' . $regex . '(\\s|\\n|$)?/is', array($this, '_censorCallback'), $content);
     }
     return $content;
 }
开发者ID:rivetweb,项目名称:old-joomla-dd-countrymap,代码行数:21,代码来源:comments.php


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