本文整理汇总了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'));
}
示例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(' ', 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);
}
示例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);
}
示例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;
}