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


PHP core_text::strrpos方法代码示例

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


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

示例1: test_strrpos

 /**
  * Tests the static strrpos.
  */
 public function test_strrpos()
 {
     $str = "Žluťoučký koníček";
     $this->assertSame(11, core_text::strrpos($str, 'o'));
 }
开发者ID:rushi963,项目名称:moodle,代码行数:8,代码来源:text_test.php

示例2: ouwiki_get_wiki_link_details

/**
 * Given the text of a wiki link (between [[ and ]]), this function converts it
 * into a safe page name by removing white space at each end and restricting to
 * max 200 characters. Also splits out the title (if provided).
 *
 * @param string $wikilink HTML code between [[ and ]]
 * @return object Object with parameters ->page (page name as PHP UTF-8
 *   string), ->title (link title as HTML; either an explicit title if specified
 *   or the start page string or the page name as html), ->rawpage (page name
 *   as HTML including possible entities, tags), and ->rawtitle (link title if
 *   specified as HTML including possible entities, tags; null if not specified)
 */
function ouwiki_get_wiki_link_details($wikilink)
{
    // Split out title if present (note: because | is lower-ascii it is safe
    // to use byte functions rather than UTF-8 ones)
    $rawtitle = null;
    $bar = strpos($wikilink, '|');
    if ($bar !== false) {
        $rawtitle = trim(substr($wikilink, $bar + 1));
        $wikilink = substr($wikilink, 0, $bar);
    }
    // Remove whitespace at either end
    $wikilink = trim($wikilink);
    $rawpage = $wikilink;
    // Remove html tags
    $wikilink = html_entity_decode(preg_replace('/<.*?>/', '', $wikilink), ENT_QUOTES, 'UTF-8');
    // Trim to 200 characters or less (note: because we don't want to cut it off
    // in the middle of a character, we use proper UTF-8 functions)
    if (core_text::strlen($wikilink) > 200) {
        $wikilink = core_text::substr($wikilink, 0, 200);
        $space = core_text::strrpos($wikilink, ' ');
        if ($space > 150) {
            $wikilink = core_text::substr($wikilink, 0, $space);
        }
    }
    // Remove non-breaking spaces
    $wikilink = str_replace(html_entity_decode('&nbsp;', ENT_QUOTES, 'UTF-8'), ' ', $wikilink);
    // What will the title be of this link?
    if ($rawtitle) {
        $title = $rawtitle;
    } else {
        if ($wikilink === '') {
            $title = get_string('startpage', 'ouwiki');
        } else {
            $title = $rawpage;
        }
    }
    // Return object with both pieces of information
    return (object) array('page' => $wikilink, 'title' => $title, 'rawtitle' => $rawtitle, 'rawpage' => $rawpage);
}
开发者ID:salmonmoose,项目名称:moodle-mod_ouwiki,代码行数:51,代码来源:locallib.php

示例3: display_name_from_file

 /**
  * Generate the name of the mod instance from the name of the file
  * (remove the extension and convert underscore => space
  *
  * @param string $filename the filename of the uploaded file
  * @return string the display name to use
  */
 protected function display_name_from_file($filename)
 {
     $pos = core_text::strrpos($filename, '.');
     if ($pos) {
         // Want to skip if $pos === 0 OR $pos === false.
         $filename = core_text::substr($filename, 0, $pos);
     }
     return str_replace('_', ' ', $filename);
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:16,代码来源:dnduploadlib.php

示例4: url_remove_dot_segments

/**
 * Filter out "." and ".." segments from a URL's path and return
 * the result.
 *
 * This function implements the "remove_dot_segments" algorithm from
 * the RFC3986 specification for URLs.
 *
 * This function supports multi-byte characters with the UTF-8 encoding,
 * per the URL specification.
 *
 * Parameters:
 * 	path	the path to filter
 *
 * Return values:
 * 	The filtered path with "." and ".." removed.
 */
function url_remove_dot_segments($path)
{
    // multi-byte character explode
    $inSegs = preg_split('!/!u', $path);
    $outSegs = array();
    foreach ($inSegs as $seg) {
        if ($seg == '' || $seg == '.') {
            continue;
        }
        if ($seg == '..') {
            array_pop($outSegs);
        } else {
            array_push($outSegs, $seg);
        }
    }
    $outPath = implode('/', $outSegs);
    if ($path[0] == '/') {
        $outPath = '/' . $outPath;
    }
    // Compare last multi-byte character against '/'.
    if ($outPath != '/' && core_text::strlen($path) - 1 == core_text::strrpos($path, '/', 'UTF-8')) {
        $outPath .= '/';
    }
    return $outPath;
}
开发者ID:evltuma,项目名称:moodle,代码行数:41,代码来源:locallib.php


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