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


PHP mb_strrpos函数代码示例

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


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

示例1: CropCharacter

 public function CropCharacter($str = '', $len = 0)
 {
     //set default return
     $return = $str;
     if ($len > 0) {
         $str = trim(strip_tags(html_entity_decode($str, ENT_COMPAT, 'utf-8')));
         $maxlen = mb_strlen($str, 'utf-8');
         if ($maxlen > $len) {
             $isMore = true;
             $tmp = mb_substr($str, 0, $len + 1, 'utf-8');
             $rPos = mb_strrpos($tmp, ' ', 0, 'utf-8');
             if ($rPos === false) {
                 $lPos = mb_strpos($str, ' ', 0, 'utf-8');
                 if ($lPos !== false) {
                     $tmp = mb_substr($str, 0, $lPos, 'utf-8');
                 } else {
                     $tmp = $str;
                     $isMore = false;
                 }
                 //end if
             } elseif ($rPos < $len) {
                 $tmp = mb_substr($tmp, 0, $rPos, 'utf-8');
             }
             //end if
             //set return
             $return = rtrim($tmp) . ($isMore ? $this->iconmore : '');
         }
         //end if
     }
     //end if
     //return
     return $return;
 }
开发者ID:Nhan-Huynh-FO,项目名称:nhan-repo,代码行数:33,代码来源:CropCharacter.php

示例2: getMD5

 private function getMD5($part)
 {
     if (substr($part, 0, 1) != "/") {
         $filename = mb_substr($part, 0, mb_strlen($part) - mb_strrpos($part, DIRECTORY_SEPARATOR));
         $sql = "SELECT `md5`\r\n\t        FROM fm_fs\r\n\t        WHERE `filename` = :filename AND pdirid = 1\r\n\t        LIMIT 1";
         $res = $this->registry['db']->prepare($sql);
         $param = array(":filename" => $filename);
         $res->execute($param);
         $row = $res->fetchAll(PDO::FETCH_ASSOC);
     } else {
         $filename = mb_substr($part, mb_strrpos($part, DIRECTORY_SEPARATOR) + 1, mb_strlen($part) - mb_strrpos($part, DIRECTORY_SEPARATOR));
         $path = mb_substr($part, 0, mb_strrpos($part, DIRECTORY_SEPARATOR));
         if ($path . "/" == $this->registry["rootPublic"] . $this->registry["path"]["upload"]) {
             $sql = "SELECT `md5`\r\n\t\t        FROM fm_fs\r\n\t\t        WHERE `filename` = :filename AND pdirid = 0\r\n\t\t        LIMIT 1";
             $res = $this->registry['db']->prepare($sql);
             $param = array(":filename" => $filename);
             $res->execute($param);
             $row = $res->fetchAll(PDO::FETCH_ASSOC);
         } else {
             $path = mb_substr($path, mb_strrpos($path, DIRECTORY_SEPARATOR) + 1, mb_strlen($path) - mb_strrpos($path, DIRECTORY_SEPARATOR));
             $sql = "SELECT f.md5\r\n\t\t        FROM fm_fs AS f\r\n\t\t        LEFT JOIN fm_dirs AS d ON (f.pdirid = d.id)\r\n\t\t        WHERE f.filename = :filename AND d.name = :path\r\n\t\t        LIMIT 1";
             $res = $this->registry['db']->prepare($sql);
             $param = array(":filename" => $filename, ":path" => $path);
             $res->execute($param);
             $row = $res->fetchAll(PDO::FETCH_ASSOC);
         }
     }
     return $row[0]["md5"];
 }
开发者ID:norayrx,项目名称:otms,代码行数:29,代码来源:Tt.php

示例3: buchnamekapitel

 public static function buchnamekapitel($eingabe)
 {
     $singularnamen = array_flip(self::$pluralnamen);
     if (isset($singularnamen[$eingabe])) {
         $eingabe = $singularnamen[$eingabe];
     }
     if (isset(self::$versnummern[$eingabe])) {
         if (count(self::$versnummern[$eingabe]) == 1 && key(self::$versnummern[$eingabe]) === 0) {
             return array($eingabe, 0);
         }
         return array($eingabe, false);
     }
     $spacepos = mb_strrpos($eingabe, ' ');
     if ($spacepos !== false) {
         $buchname = mb_substr($eingabe, 0, $spacepos);
         $kapitel = mb_substr($eingabe, $spacepos + 1);
         if (isset($singularnamen[$buchname])) {
             $buchname = $singularnamen[$buchname];
         }
         if (isset(self::$versnummern[$buchname]) && isset(self::$versnummern[$buchname][$kapitel])) {
             return array($buchname, $kapitel);
         }
     }
     return array(false, false);
 }
开发者ID:Offene-Bibel,项目名称:offene-bibel.de,代码行数:25,代码来源:OffeneBibel_abk.php

示例4: generateSingle

 /**
  * Generate a fake member account
  *
  * @param   array   $values Generator form values
  * @return  string  Progress message
  */
 public function generateSingle(array $values)
 {
     /* Create Member */
     $member = new \IPS\Member();
     $member->name = $values['__generator_message'] = $this->generator->userName();
     $password = isset($values['password']) ? $member->name : $this->generator->password();
     $member->email = $this->generator->email();
     $member->members_pass_salt = $member->generateSalt();
     $member->members_pass_hash = $member->encryptedPassword($password);
     $member->allow_admin_mails = 0;
     $member->member_group_id = $values['member_group'];
     $member->members_bitoptions['view_sigs'] = TRUE;
     if ($values['profile_photo']) {
         $photoUrl = new \IPS\Http\Url($this->generator->photoUrl());
         $response = $photoUrl->request()->get();
         $filename = preg_replace("/(.+?)(\\?|\$)/", "\$1", mb_substr((string) $photoUrl, mb_strrpos((string) $photoUrl, '/') + 1));
         $photoFile = \IPS\File::create('core_Profile', $filename, $response);
         $member->pp_photo_type = 'custom';
         $member->pp_main_photo = NULL;
         $member->pp_main_photo = (string) $photoFile;
         $thumbnail = $photoFile->thumbnail('core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE, TRUE);
         $member->pp_thumb_photo = (string) $thumbnail;
     }
     $member->save();
     $this->map(static::$activeRecordClass, $member->member_id);
     return \IPS\Member::loggedIn()->language()->addToStack(static::$message, true, array('sprintf' => array($member->name)));
 }
开发者ID:alobimday,项目名称:IPS-Faker,代码行数:33,代码来源:Members.php

示例5: gelSummary

function gelSummary($content, $length = 300)
{
    $filter = array("'<script[^>]*?>.*?</script>'si", "'<img.*?>'i", "'<iframe.*?>.*?<\\/iframe>'si", "'<font.*?>.*?<\\/font>'si", "'<strong.*?>.*?<\\/strong>'i", "'<b.*?>.*?<\\/b>'si", "'<[\\/\\!]*?[^<>]*?>'si", "'([\r\n])[\\s]+'", "'&(quot|#34);'i", "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&#(\\d+);'e", "'(nbsp;|ldquo;|rdquo;|<br>|<br/>|<br /|br/|  |    |/pp|p)'i");
    $endMarks = array('.', '。', ';', ';', '?', '?', '!', '!');
    //去掉头尾空格
    //	$content = strip_tags($content);
    //	$content = trim($content);
    //截取前面total个字符
    //	echo $length.'<hr>';
    //	echo $content.'<hr>';
    //去掉过滤字符
    $content = preg_replace($filter, '', $content);
    //	echo 'filter:'.$content.'<hr>';
    $content = strip_tags($content);
    $summary = mb_substr($content, 0, $length, 'utf-8');
    //	echo '截取length:'.$summary.'<hr>';
    $summary = str_replace(array(' ', '\'', '"', '’', '‘', '“', '”'), '', $summary);
    //	echo '去掉空字符:'.$summary.'<hr>';
    //查找终止字符
    $endPos = 0;
    foreach ($endMarks as $endMark) {
        $endIndex = mb_strrpos($summary, $endMark, 'utf-8');
        $endPos = $endIndex > $endPos ? $endIndex : $endPos;
    }
    $summary = mb_substr($summary, 0, $endPos + 1, 'utf-8');
    $summary = str_replace(' ', '', $summary);
    //	echo '寻找结尾:'.$summary.'<hr>';
    return $summary;
}
开发者ID:xujianjun,项目名称:touzilicai,代码行数:29,代码来源:addsummary.php

示例6: uploadFile

	/**
	 * Copy an image uploaded with HTML form to the specified directory.
	 * In view scripts one should use something like <img src="{$fileBaseDir}/{@return}"/>
	 *
	 * @param string $paramName Parameter name as it passed by a form.
	 * @param string $fileBaseDir A base directory constant for the file (should be used in view scripts as prefix before $filePath from DB table).
	 * @return string New file's name.
	 * @throws CException 
	 */
	public static function uploadFile($paramName, $fileBaseDir)
	{
		if(empty($_FILES[AutoAdmin::INPUT_PREFIX]['tmp_name'][$paramName]) || !empty($_FILES[AutoAdmin::INPUT_PREFIX]['error'][$paramName]))
			throw new AAException(Yii::t('AutoAdmin.errors', 'An error occured with uploading of the file for field "{field}"', array('{field}'=>$paramName)));
		$uploadedFileName =& $_FILES[AutoAdmin::INPUT_PREFIX]['name'][$paramName];

		$newfname = '';
		$toDir = self::srcToPath($fileBaseDir);
		$newfname = mb_strtolower(mb_substr($uploadedFileName, 0, mb_strrpos($uploadedFileName, '.')));
		$newfname = AAHelperText::translite($newfname);
		$newfname = str_replace(' ', '_', $newfname);
		$newfname = preg_replace('/[^a-z\-\_0-9]/ui', '', $newfname);
		if(mb_strlen($newfname)>60)
			$newfname = mb_substr($newfname, 0, 60);
		$ext = mb_substr(mb_strrchr($uploadedFileName, '.'), 1);
		if(!is_dir($toDir))
		{
			if(!mkdir($toDir, 0777, true))
				throw new AAException(Yii::t('AutoAdmin.errors', 'The directory "{dirname}" cannot be created', array('{dirname}'=>$toDir)));
		}
		while(file_exists($toDir.DIRECTORY_SEPARATOR.$newfname.'.'.$ext))
			$newfname .= '_'.rand(0, 9);
		$newfname .= ".{$ext}";
		if(!copy($_FILES[AutoAdmin::INPUT_PREFIX]['tmp_name'][$paramName], $toDir.DIRECTORY_SEPARATOR.$newfname))
			throw new AAException(Yii::t('AutoAdmin.errors', 'The file ({filename}) cannot be copied', array('{filename}'=>$newfname)));
		return $newfname;
	}
开发者ID:nico13051995,项目名称:IntITA,代码行数:36,代码来源:AAHelperFile.php

示例7: Shorten

 /**
  * Cuts off text of desired length
  * @param string $str Input tect
  * @param int $length Desired length
  * @param bool $respectWords Set true so no words are broken
  * @param bool $noEllipsis true if no ellipsis shall be added
  * @param bool $forceEllipsis True if ellipsis shall be added even if text is shorter then desired
  * @param bool $entityDecode True if an entity decode shall be performed
  * @return string 
  */
 static function Shorten($str, $length = 32, $respectWords = false, $noEllipsis = false, $forceEllipsis = false, $entityDecode = false)
 {
     if ($entityDecode) {
         $str = html_entity_decode($str, ENT_COMPAT, 'utf-8');
     }
     $str = String::Trim(strip_tags($str));
     if (strlen($str) <= $length) {
         if ($forceEllipsis) {
             return self::CorrectSpaces($str) . "...";
         } else {
             return self::CorrectSpaces($str);
         }
     }
     $str = mb_substr($str, 0, $length - 3, 'utf-8');
     if ($respectWords) {
         $pos = mb_strrpos($str, " ", -1, 'utf-8');
         if ($pos > $length / 2) {
             $str = mb_substr($str, 0, $pos, 'utf-8');
         }
     }
     $str = self::CorrectSpaces($str);
     if (!$noEllipsis) {
         $str = $str . "...";
     }
     return $str;
 }
开发者ID:agentmedia,项目名称:phine-framework,代码行数:36,代码来源:Text.php

示例8: getForMap

 public function getForMap()
 {
     $pageName = $this->request->getVal('title');
     $oTitle = Title::newFromText($pageName);
     if (empty($oTitle) || !$oTitle->exists()) {
         return array();
     }
     $pageId = $oTitle->getArticleId();
     // TODO: getImages() are not cached
     $imageServing = new ImageServing(array($pageId), 100, array('w' => 1, 'h' => 1));
     $images = $imageServing->getImages(1);
     if (!empty($images[$pageId][0]['url'])) {
         $imageUrl = $images[$pageId][0]['url'];
     } else {
         $imageUrl = '';
     }
     $oArticleService = F::Build('ArticleService');
     $oArticleService->setArticleById($pageId);
     $textSnippet = $oArticleService->getTextSnippet(120);
     $strPos = mb_strrpos($textSnippet, ' ');
     $textSnippet = mb_substr($textSnippet, 0, $strPos);
     $textSnippet .= ' ...';
     $this->setVal('title', $oTitle->getText());
     $this->setVal('imgUrl', $imageUrl);
     $this->setVal('articleUrl', $oTitle->getLocalUrl());
     $this->setVal('textSnippet', $textSnippet);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:GamingMapsController.class.php

示例9: applyTransforms

function applyTransforms($s, $transforms)
{
    $copy = $s;
    $positions = array();
    for ($i = count($transforms) - 1; $i >= 0; $i--) {
        $t = $transforms[$i];
        $pos = $t->from == '-' ? mb_strlen($copy) : mb_strrpos($copy, $t->from);
        $positions[$i] = $pos;
        $copy = mb_substr($copy, 0, $pos);
    }
    $result = '';
    for ($i = count($transforms) - 1; $i >= 0; $i--) {
        $t = $transforms[$i];
        $pos = $positions[$i];
        $len = mb_strlen($s);
        $afterFrom = $pos + mb_strlen($t->from);
        if ($len > $afterFrom) {
            $result = mb_substr($s, $afterFrom) . $result;
        }
        $result = $t->to . $result;
        $s = mb_substr($s, 0, $pos);
    }
    $result = $s . $result;
    return $result;
}
开发者ID:florinp,项目名称:dexonline,代码行数:25,代码来源:testTransformExtractor.php

示例10: strchop

 /**
  * function strchop
  * DESC: Cuts a string to a given length and will also append a specified
  * string on the end. This method truncates to the nearest blank space to
  * avoid words being chopped. Updated to include multibyte char support
  * and error handline where text has no blank space
  *
  * USAGE EXAMPLE: to truncate a string to near 50 characters and
  * append "..." on the end, strchop($string, 50, "...")
  *
  * @param string $string
  * @param int $truncateLength
  * @param string $endString
  * @return string
  */
 public static function strchop($string, $truncateLength, $endString = false)
 {
     $strlen = mb_strlen($string, "UTF-8");
     // check if string length is over the specified truncate value
     // if it isn't simply return the string
     if ($strlen > $truncateLength) {
         //cut the string
         $cutStr = trim(mb_substr($string, 0, $truncateLength, "UTF-8"));
         //search for last blank space character
         $blankPos = mb_strrpos($cutStr, " ", "UTF-8");
         if (!$blankPos) {
             error_log("no blank pos in string of {$truncateLength} character length: " . __METHOD__);
             return $cutStr . "...";
         }
         //cut string again to this new position
         $cutStr = trim(mb_substr($string, 0, $blankPos, "UTF-8"));
         //append endString if it exists
         if (isset($endString)) {
             $cutStr = $cutStr . $endString;
         }
         return $cutStr;
     } else {
         return $string;
     }
 }
开发者ID:ThibautLeger,项目名称:123-mini,代码行数:40,代码来源:Strings.php

示例11: smarty_modifier_cutcontent

/**
 * 文本截断+url链接加上gate.baidu.com前缀,自动处理超链接的截断
 * @param  String  $str    原始内容,其中有a 标签
 * @param  integer $len    截取内容长度
 * @param  integer $urllen url截断显示的长度
 * @return String          截断后的文本
 */
function smarty_modifier_cutcontent($str, $len = 1500, $urllen = 30)
{
    //防止br被切割,先转成\n,截取后再fis_addbr中再转回来
    $str = str_replace("<br />", "\n", $str);
    //parse before cut
    $str = fis_parselink($str, $urllen);
    $lenarray = array('34', '50');
    //no need cut
    if (mb_strlen($str) < $len) {
        return fis_addbr($str);
    }
    $str = mb_substr($str, 0, $len, 'utf-8');
    //find last <a and </a> and check if it is ok
    $pos_of_a = mb_strrpos($str, '<a');
    if ($pos_of_a === false) {
        return fis_addbr($str);
    }
    $pos_of_aend = mb_strrpos($str, '</a>');
    //</a> is after <a>
    if ($pos_of_a < $pos_of_aend) {
        return fis_addbr($str);
    }
    //</a> is not after <a>
    $str = mb_substr($str, 0, $pos_of_a, 'utf-8');
    //$str = fis_addpoint($str);
    return fis_addbr($str);
}
开发者ID:jinzhan,项目名称:tomato,代码行数:34,代码来源:modifier.cutcontent.php

示例12: normalizeFiles

 /**
  * Normalizes raw files data for the existing files list composing.
  * @param array $rawFiles raw files to process.
  * @return array normalized files data
  * @throws CException on failure.
  */
 protected function normalizeFiles(array $rawFiles)
 {
     $currentRoute = Yii::app()->getController()->getRoute();
     $pos = mb_strrpos($currentRoute, '/');
     if ($pos !== false) {
         $baseRoute = mb_substr($currentRoute, 0, $pos);
     } else {
         $baseRoute = $currentRoute;
     }
     $normalizedFiles = array();
     foreach ($rawFiles as $rawFile) {
         if (is_object($rawFile)) {
             $normalizedFile = array('id' => $rawFile->id, 'name' => $rawFile->name);
         } elseif (is_array($rawFile)) {
             $normalizedFile = $rawFile;
         } else {
             throw new CException('File should either array or object!');
         }
         if (empty($normalizedFile['downloadUrl'])) {
             $normalizedFile['downloadUrl'] = Yii::app()->createUrl($this->baseDownloadUrl, array('id' => $normalizedFile['id']));
         }
         if (empty($normalizedFile['deleteUrl'])) {
             $normalizedFile['deleteUrl'] = Yii::app()->createUrl($this->baseDeleteUrl, array('id' => $normalizedFile['id']));
         }
         $normalizedFiles[] = $normalizedFile;
     }
     return $normalizedFiles;
 }
开发者ID:yii-ext,项目名称:plupload,代码行数:34,代码来源:FileUploaderWidget.php

示例13: getFileExtension

 /**
  * Returns the extension of the original file name.
  * 
  * @return	string
  */
 public function getFileExtension()
 {
     if (($position = mb_strrpos($this->filename, '.')) !== false) {
         return mb_strtolower(mb_substr($this->filename, $position + 1));
     }
     return '';
 }
开发者ID:Griborim,项目名称:de.incendium.cms.filebase,代码行数:12,代码来源:EntryFile.class.php

示例14: copyImage

	function copyImage($var, $uploadDir='/i/other')
	{
		$newFileName = '';
		$newFileName = mb_strtolower(mb_substr($_FILES[$var]['name'], 0, mb_strrpos($_FILES[$var]['name'], '.')));
		$newFileName = AAHelperText::translite($newFileName);
		$newFileName = str_replace(' ', '_', $newFileName);
		$newFileName = preg_replace('/[^a-z\-\_0-9]/ui', '', $newFileName);
		if(mb_strlen($newFileName)>60)
			$newFileName = mb_substr($newFileName, 0, 60);
		$ext = mb_strrchr($_FILES[$var]['name'], '.');
		$newFileName .= $ext;
		$fileLinkDir = $uploadDir;
		$targetPath = Yii::app()->basePath.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.Yii::app()->modules['autoadmin']['wwwDirName'].str_replace('/', DIRECTORY_SEPARATOR, $uploadDir);
		if(!is_dir($targetPath))
		{
			if(!mkdir($targetPath))
				throw new CHttpException(406, "Указанная в настройках директория [{$fileLinkDir}] не существует и не может быть создана.");
		}
		$targetPath .= DIRECTORY_SEPARATOR.$newFileName;
		if(!copy($_FILES[$var]['tmp_name'], $targetPath))
			throw new CHttpException(406, "Файл невозможно сохранить в указанной в настройках директории [{$fileLinkDir}]. Вероятнее всего, проблемы с правами.");
		if(!getimagesize($targetPath))
		{
			throw new CHttpException(406, "Загружаемый файл не является изображением допустимого формата.");
		}
		return $fileLinkDir.'/'.$newFileName;
	}
开发者ID:nico13051995,项目名称:IntITA,代码行数:27,代码来源:AAFileController.php

示例15: testmb_strpos

 /**
  * @covers Patchwork\PHP\Override\Mbstring::mb_strpos
  * @covers Patchwork\PHP\Override\Mbstring::mb_stripos
  * @covers Patchwork\PHP\Override\Mbstring::mb_strrpos
  * @covers Patchwork\PHP\Override\Mbstring::mb_strripos
  */
 function testmb_strpos()
 {
     $this->assertSame(false, @mb_strpos('abc', ''));
     $this->assertSame(false, @mb_strpos('abc', 'a', -1));
     $this->assertSame(false, mb_strpos('abc', 'd'));
     $this->assertSame(false, mb_strpos('abc', 'a', 3));
     $this->assertSame(1, mb_strpos('한국어', '국'));
     $this->assertSame(3, mb_stripos('DÉJÀ', 'à'));
     $this->assertSame(false, mb_strrpos('한국어', ''));
     $this->assertSame(1, mb_strrpos('한국어', '국'));
     $this->assertSame(3, mb_strripos('DÉJÀ', 'à'));
     $this->assertSame(1, mb_stripos('aςσb', 'ΣΣ'));
     $this->assertSame(1, mb_strripos('aςσb', 'ΣΣ'));
     $this->assertSame(false, @p::mb_strpos('abc', ''));
     $this->assertSame(false, @p::mb_strpos('abc', 'a', -1));
     $this->assertSame(false, p::mb_strpos('abc', 'd'));
     $this->assertSame(false, p::mb_strpos('abc', 'a', 3));
     $this->assertSame(1, p::mb_strpos('한국어', '국'));
     $this->assertSame(3, p::mb_stripos('DÉJÀ', 'à'));
     $this->assertSame(false, p::mb_strrpos('한국어', ''));
     $this->assertSame(1, p::mb_strrpos('한국어', '국'));
     $this->assertSame(3, p::mb_strripos('DÉJÀ', 'à'));
     $this->assertSame(1, p::mb_stripos('aςσb', 'ΣΣ'));
     $this->assertSame(1, p::mb_strripos('aςσb', 'ΣΣ'));
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:31,代码来源:MbstringTest.php


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