本文整理汇总了PHP中utf8_trim函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_trim函数的具体用法?PHP utf8_trim怎么用?PHP utf8_trim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_trim函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _init_search_query_object
function _init_search_query_object()
{
$request = request::instance();
if ($search_query = utf8_trim($request->get_attribute('search_query'))) {
$this->query_object->add(search_text_normalizer::process($search_query));
}
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:7,代码来源:search_datasource.class.php
示例2: getMessageText
public function getMessageText($inputName, XenForo_Input $input, $htmlCharacterLimit = -1)
{
$messageText = parent::getMessageText($inputName, $input, $htmlCharacterLimit);
if (utf8_trim($messageText) === 'lipsum') {
$lipsum = @file_get_contents('http://www.lipsum.com/feed/json');
if (!empty($lipsum)) {
$lipsum = @json_decode($lipsum, true);
if (!empty($lipsum['feed']['lipsum'])) {
$messageText = sprintf("%s\n\nBy [URL=%s]%s[/URL]", $lipsum['feed']['lipsum'], $lipsum['feed']['creditlink'], $lipsum['feed']['creditname']);
}
}
}
return $messageText;
}
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:14,代码来源:Editor.php
示例3: get_search_query_object
function get_search_query_object()
{
if ($this->query_object) {
return $this->query_object;
}
$request = request::instance();
if (!($search_query = utf8_trim($request->get_attribute('search_query')))) {
return null;
}
$this->query_object = new search_query();
$search_query = search_text_normalizer::process($search_query);
$words = explode(' ', $search_query);
foreach ($words as $word) {
$this->query_object->add($word);
}
return $this->query_object;
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:17,代码来源:fulltext_search_datasource.class.php
示例4: parse_var_file
/**
* Parses a var file into a data structure. Used in conjunction with an
* Importtag
*/
function parse_var_file($filename)
{
$result = array();
$raw_lines = file($filename);
while (list(, $line) = each($raw_lines)) {
$equal_pos = utf8_strpos($line, '=');
if ($equal_pos === false) {
$result[utf8_trim($line)] = null;
} else {
$key = utf8_trim(utf8_substr($line, 0, $equal_pos));
if (utf8_strlen($key) > 0) {
$result[$key] = utf8_trim(utf8_substr($line, $equal_pos + 1));
}
}
}
return $result;
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:21,代码来源:var_file_compiler.inc.php
示例5: substrs
/**
* 双字节字符截取
*
* @param string $content
* @param int $length
* @return string
*/
function substrs($content, $length)
{
if (!defined('CFG_CHARSET')) {
define('CFG_CHARSET', 'utf-8');
}
if ($length && strlen($content) > $length) {
if (CFG_CHARSET != 'utf-8') {
$retstr = '';
for ($i = 0; $i < $length - 2; $i++) {
$retstr .= ord($content[$i]) > 127 ? $content[$i] . $content[++$i] : $content[$i];
}
return $retstr . ' ..';
} else {
return utf8_trim(substr($content, 0, $length * 3));
}
}
return $content;
}
开发者ID:XiaoFeiFeng,项目名称:demo,代码行数:25,代码来源:Util.inc.php
示例6: utf8_basename
/**
* Returns filename component of path
*
* @author Lars Knickrehm <[email protected]>
* @category Library
* @copyright Copyright © 2009 Lars Knickrehm
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License
* @link http://php.net/manual/function.basename.php
* @package UTF-8
* @param string $path A path. Both slash (/) and backslash (\) are used as directory separator character.
* @param string $suffix If the filename ends in suffix this will also be cut off.
* @return string Base name of the given path
* @since Version 0.5.0
* @version 0.5.0
*/
function utf8_basename($path, $suffix = '')
{
// Change backslash (\) to slash (/)
$path = utf8_trim(strtr($path, array('\\' => '/')), '/');
// Get basename
$i = utf8_strrpos($path, '/');
if ($i !== false) {
$path = utf8_substr($path, $i + 1);
}
// Handle suffix
if ($suffix !== '') {
$position = utf8_strrpos($path, $suffix);
if ($position !== false) {
$path = utf8_substr($path, 0, $position);
}
}
return $path;
}
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:33,代码来源:basename.php
示例7: process
function process($content)
{
$content = utf8_strtolower($content);
$content = utf8_str_replace("\n", ' ', $content);
$content = utf8_str_replace("\t", ' ', $content);
$content = utf8_str_replace("\r", ' ', $content);
$search = array("'<script[^>]*?>.*?</script>'si", "'<[\\/\\!]*?[^<>]*?>'si", "'([\r\n])[\\s]+'");
$replace = array('', ' ', ' ');
$content = preg_replace($search, $replace, $content);
$content = preg_replace("#(\\.){2,}#", ' ', $content);
$content = preg_replace("#^\\.#", ' ', $content);
$content = preg_replace("#\\s\\.#", ' ', $content);
$content = preg_replace("#\\.\\s#", ' ', $content);
$content = preg_replace("#\\.\$#", ' ', $content);
//non utf8 chars(�,�)
$content = preg_replace("#(\\s|^)(\"|'|`|�|�)(\\w)#", '\\1\\3', $content);
$content = preg_replace("#(\\w)(\"|'|`|�|�)(\\s|\$)#u", '\\1\\3', $content);
$content = utf8_str_replace(" ", ' ', $content);
$content = utf8_str_replace(":", ' ', $content);
$content = utf8_str_replace(",", ' ', $content);
$content = utf8_str_replace(";", ' ', $content);
$content = utf8_str_replace("(", ' ', $content);
$content = utf8_str_replace(")", ' ', $content);
$content = utf8_str_replace("-", ' ', $content);
$content = utf8_str_replace("+", ' ', $content);
$content = utf8_str_replace("/", ' ', $content);
$content = utf8_str_replace("!", ' ', $content);
$content = utf8_str_replace("?", ' ', $content);
$content = utf8_str_replace("[", ' ', $content);
$content = utf8_str_replace("]", ' ', $content);
$content = utf8_str_replace("\$", ' ', $content);
$content = utf8_str_replace("\\", ' ', $content);
$content = utf8_str_replace("<", ' ', $content);
$content = utf8_str_replace(">", ' ', $content);
$content = utf8_str_replace("*", ' ', $content);
$content = utf8_trim(preg_replace("~\\s+~u", ' ', $content));
return $content;
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:38,代码来源:search_text_normalizer.class.php
示例8: pun_trim
function pun_trim($str, $charlist = false)
{
return is_string($str) ? utf8_trim($str, $charlist) : '';
}
开发者ID:HawesDomingue,项目名称:mechanic-watson,代码行数:4,代码来源:functions.php
示例9: userorg_update_by_name
/**
* Assign user to organization AND Try to create new organization if it doesn't exist yet
*
* @param object User
* @param string Organization name
* @param string Organization role
*/
function userorg_update_by_name(&$User, $org_name, $org_role = '')
{
$org_name = utf8_trim($org_name);
if (empty($org_name)) {
// Don't update an user organization with empty name:
return;
}
if (is_null($this->userorgs)) {
// Initialize array to keep what organizations should be assigned to the user:
$this->userorgs = array();
}
// Get organization ID by name AND save it in array to update after user insertion:
$org_ID = $this->userorg_get_by_name($org_name);
$this->userorgs[$org_ID] = $org_role;
}
开发者ID:b2evolution,项目名称:ldap_plugin,代码行数:22,代码来源:_ldap.plugin.php
示例10: get_user_avatar_url
if ($is_logged_in) {
if ($User->ID == $current_User->ID && !$User->has_avatar()) {
// If user hasn't an avatar, add a link to go for uploading of avatar
$avatar_imgtag = '<a href="' . get_user_avatar_url() . '">' . $avatar_imgtag . '</a>';
}
}
echo $params['profile_avatar_before'] . $avatar_imgtag . $params['profile_avatar_after'];
// First Last Names:
$first_last_name = '';
if ($Settings->get('firstname_editing') != 'hidden' && $User->get('firstname') != '') {
$first_last_name .= $User->get('firstname');
}
if ($Settings->get('lastname_editing') != 'hidden' && $User->get('lastname') != '') {
$first_last_name .= ' ' . $User->get('lastname');
}
$first_last_name = utf8_trim($first_last_name);
if (!empty($first_last_name)) {
// Display first last name of it is not empty
echo '<h1>' . $first_last_name . '</h1>';
}
// Nickname:
if ($Settings->get('nickname_editing') != 'hidden' && $User->get('nickname') != '') {
echo '<h2>' . $User->get('nickname') . '</h2>';
}
// Login:
echo '<h2 class="text-muted">' . $User->get('login') . '</h2>';
echo '<hr class="profile_separator" />' . "\n";
// Gender & age group:
$gender_age_group = $User->get_gender();
if (!empty($User->age_min) || !empty($User->age_max)) {
if (!empty($gender_age_group)) {
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:31,代码来源:_user.disp.php
示例11: trim
/**
* UTF-8 aware replacement for trim()
*
* Strip whitespace (or other characters) from the beginning and end of a string. You only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise trim will work normally on a UTF-8 string
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional characters to trim
*
* @return string The trimmed string
*
* @see http://www.php.net/trim
* @since 1.3.0
*/
public static function trim($str, $charlist = false)
{
if (empty($charlist) && $charlist !== false) {
return $str;
}
if ($charlist === false) {
return utf8_trim($str);
}
return utf8_trim($str, $charlist);
}
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:24,代码来源:StringHelper.php
示例12: getNormalizedTagText
public static function getNormalizedTagText($tagText)
{
$tagText = utf8_trim($tagText);
$tagText = utf8_strtolower($tagText);
return $tagText;
}
开发者ID:Sywooch,项目名称:forums,代码行数:6,代码来源:Helper.php
示例13: processEditProjectForm
function processEditProjectForm()
{
global $manager;
$id = $_POST['id'];
$title = $_POST['title'];
$slug = empty($_POST['slug']) ? $manager->clerk->simple_name($title) : $_POST['slug'];
$oldSlug = $_POST['oldslug'];
$now = getdate();
$date = mktime($now["hours"], $now["minutes"], $now["seconds"], $_POST["date_month"], $_POST["date_day"], $_POST["date_year"]);
$tags = $_POST['tags'];
$publish = $_POST['publish'];
$paths = $manager->getSetting("projects_path");
$paths = array('path' => $paths['data1'], 'url' => $paths['data2']);
if ($_POST['submit'] == "save") {
if ($manager->clerk->query_countRows("projects", "WHERE slug= '{$slug}' AND id != '{$id}'") >= 1) {
$manager->message(0, false, 'A project with the simple name/slug <em>"' . $slug . '"</em> already exists! Please choose a new one.');
return false;
}
if ($manager->clerk->query_edit("projects", "title= '{$title}', slug= '{$slug}', date= '{$date}', publish= '{$publish}'", "WHERE id= '{$id}'")) {
$manager->message(1, false, "Project <em>{$title}</em> saved!");
// Handle tags...
if (!empty($tags)) {
$tags = explode(",", $tags);
$total = count($tags);
$manager->clerk->query_delete("projects_to_tags", "WHERE projectid= '{$id}'");
$count = 0;
foreach ($tags as $c) {
$count++;
$query .= "('" . utf8_trim($c) . "', '{$id}')";
$query .= $count == $total ? "" : ", ";
}
$manager->clerk->query_insert("projects_to_tags", "tag, projectid", $query, true);
} else {
$manager->clerk->query_delete("projects_to_tags", "WHERE projectid= '{$id}'");
}
// Handle renaming
if ($slug != $oldSlug) {
rename($paths['path'] . $oldSlug, $paths['path'] . $slug);
}
} else {
$manager->message(0, true, "This project could not be saved!");
}
}
}
开发者ID:Codechanic,项目名称:The-Secretary,代码行数:44,代码来源:projects_manage.php
示例14: snippet
/**
* @param string $string
* @param int $maxLength
* @param array $options
*
* @return string
*/
public static function snippet($string, $maxLength = 0, array $options = array())
{
$options = array_merge(array('previewBreakBbCode' => 'prbreak', 'ellipsis' => '…'), $options);
if (!empty($options['previewBreakBbCode']) && preg_match(sprintf('#\\[%1$s\\](?<preview>.*)\\[/%1$s\\]#', preg_quote($options['previewBreakBbCode'], '#')), $string, $matches, PREG_OFFSET_CAPTURE)) {
// preview break bbcode found
if (!empty($matches['preview'][0])) {
// preview text specified, use it directly
$string = $matches['preview'][0];
$maxLength = 0;
} else {
// use content before the found bbcode to continue
$string = substr($string, 0, $matches[0][1]);
$maxLength = 0;
}
}
$snippet = XenForo_Template_Helper_Core::callHelper('snippet', array($string, $maxLength, $options));
// TODO: find better way to avoid having to call this
$snippet = htmlspecialchars_decode($snippet);
if ($maxLength == 0 || $maxLength > utf8_strlen($string)) {
return $snippet;
}
$offset = 0;
$stack = array();
while (true) {
$startPos = utf8_strpos($snippet, '<', $offset);
if ($startPos !== false) {
$endPos = utf8_strpos($snippet, '>', $startPos);
if ($endPos === false) {
// we found a partial open tag, best to delete the whole thing
$snippet = utf8_substr($snippet, 0, $startPos) . $options['ellipsis'];
break;
}
$foundLength = $endPos - $startPos - 1;
$found = utf8_substr($snippet, $startPos + 1, $foundLength);
$offset = $endPos;
if (preg_match('#^(?<closing>/?)(?<tag>\\w+)#', $found, $matches)) {
$tag = $matches['tag'];
$isClosing = !empty($matches['closing']);
$isSelfClosing = !$isClosing && utf8_substr($found, $foundLength - 1, 1) === '/';
if ($isClosing) {
$lastInStack = null;
if (count($stack) > 0) {
$lastInStack = array_pop($stack);
}
if ($lastInStack !== $tag) {
// found tag does not match the one in stack
$replacement = '';
// first we have to close the one in stack
if ($lastInStack !== null) {
$replacement .= sprintf('</%s>', $tag);
}
// then we have to self close the found tag
$replacement .= utf8_substr($snippet, $startPos, $endPos - $startPos - 1);
$replacement .= '/>';
// do the replacement
$snippet = utf8_substr_replace($snippet, $replacement, $startPos, $endPos - $startPos);
$offset = $startPos + utf8_strlen($snippet);
}
} elseif ($isSelfClosing) {
// do nothing
} else {
// is opening tag
$stack[] = $tag;
}
}
} else {
break;
}
}
while (!empty($stack)) {
$snippet .= sprintf('</%s>', array_pop($stack));
}
$snippet = utf8_trim($snippet);
if ($snippet === '') {
// this is bad...
// happens if the $maxLength is too low and for some reason the very first tag cannot finish
$snippet = utf8_trim(strip_tags($string));
if ($snippet !== '') {
$snippet = XenForo_Template_Helper_Core::callHelper('snippet', array($snippet, $maxLength, $options));
} else {
// this is super bad...
// the string is one big html tag and it is too damn long
$snippet = $options['ellipsis'];
}
}
return $snippet;
}
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:94,代码来源:Html.php
示例15: score_tags
/**
* Return a search score for the given text and search keywords
*
* @param string Text to score
* @param string The search keywords to score by
* @param integer Score multiplier
* @return integer Result score
*/
function score_tags($tag_name, $search_term, $score_weight = 4)
{
$score = 0.0;
$scores_map = array();
if ($tag_name == utf8_trim($search_term)) {
// We use only EXACT match for post tags:
$score = $score_weight;
$scores_map['tags'] = $score;
}
return array('score' => $score, 'score_weight' => $score_weight, 'map' => $scores_map);
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:19,代码来源:_search.funcs.php
示例16: substrs
function substrs($content, $length, $add = 'Y')
{
if (strlen($content) > $length) {
if ($GLOBALS['db_charset'] != 'utf-8') {
$retstr = '';
for ($i = 0; $i < $length - 2; $i++) {
$retstr .= ord($content[$i]) > 127 ? $content[$i] . $content[++$i] : $content[$i];
}
return $retstr . ($add == 'Y' ? ' ..' : '');
}
return utf8_trim(substr($content, 0, $length)) . ($add == 'Y' ? ' ..' : '');
}
return $content;
}
开发者ID:adi00,项目名称:wumaproject,代码行数:14,代码来源:common.php
示例17: mul_excerpt
function mul_excerpt($excerpt)
{
$myexcerpt = substr($excerpt, 0, 255);
return utf8_trim($myexcerpt) . '... ';
}
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:5,代码来源:mulberrykit.php
示例18: _parse_string
function _parse_string(&$contents)
{
$lines =& preg_split("#\r\n|\r|\n#u", $contents);
unset($contents);
if ($lines === false) {
debug::write_error("'{$this->file_path}' is empty", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
return false;
}
$current_group = 'default';
if (count($lines) == 0) {
return false;
}
// check for charset
if (preg_match("/#charset[^=]*=(.+)/u", $lines[0], $match)) {
$this->charset = utf8_trim($match[1]);
}
foreach ($lines as $line) {
if (($line = utf8_trim($line)) == '') {
continue;
}
// removing comments after #, not after # inside ""
$line = preg_replace('/([^"#]+|"(.*?)")|(#[^#]*)/u', "\\1", $line);
// check for new group
if (preg_match("#^\\[(.+)\\]\\s*\$#u", $line, $new_group_name_array)) {
$new_group_name = utf8_trim($new_group_name_array[1]);
$current_group = $new_group_name;
$this->group_values[$current_group] = array();
continue;
}
// check for variable
if (preg_match("#^([a-zA-Z0-9_-]+)(\\[([a-zA-Z0-9_-]*)\\]){0,1}(\\s*)=(.*)\$#u", $line, $value_array)) {
$var_name = utf8_trim($value_array[1]);
$var_value = utf8_trim($value_array[5]);
if (preg_match('/^"(.*)"$/u', $var_value, $m)) {
$var_value = $m[1];
}
if ($value_array[2]) {
if ($value_array[3]) {
$key_name = $value_array[3];
if (isset($this->group_values[$current_group][$var_name]) && is_array($this->group_values[$current_group][$var_name])) {
$this->group_values[$current_group][$var_name][$key_name] = $var_value;
} else {
$this->group_values[$current_group][$var_name] = array($key_name => $var_value);
}
} else {
if (isset($this->group_values[$current_group][$var_name]) && is_array($this->group_values[$current_group][$var_name])) {
$this->group_values[$current_group][$var_name][] = $var_value;
} else {
$this->group_values[$current_group][$var_name] = array($var_value);
}
}
} else {
$this->group_values[$current_group][$var_name] = $var_value;
}
}
}
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:57,代码来源:ini.class.php
示例19: trim
/**
* UTF-8 aware replacement for trim()
* Strip whitespace (or other characters) from the beginning and end of a string
* Note: you only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise trim will
* work normally on a UTF-8 string
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional characters to trim
*
* @return string The trimmed string
*
* @see http://www.php.net/trim
* @since 2.0
*/
public static function trim($str, $charlist = null)
{
if (empty($charlist) && $charlist !== null) {
return $str;
}
if (!function_exists('utf8_trim')) {
require_once __DIR__ . '/phputf8/trim.php';
}
if ($charlist === null) {
return utf8_trim($str);
}
return utf8_trim($str, $charlist);
}
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:28,代码来源:Utf8String.php
示例20: apip_excerpt
/**
* 作用: 精确处理中文excerpt
* 来源: 综合WP CN Excerpt和中文工具箱
* URL: http://yan.me/dia, http://weibo.com/joychaocc
*/
function apip_excerpt($text)
{
global $apip_options;
//erase short codes
$text = get_the_content();
$text = strip_shortcodes($text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
//return and spaces
$search = array('/<br\\s*\\/?>/' => "\n", '/\\n\\n/' => "\n", '/ /i' => '');
$text = preg_replace(array_keys($search), $search, $text);
if ($apip_options['excerpt_length'] > 0) {
$len = $apip_options['excerpt_length'];
} else {
$len = 180;
}
$text = mb_substr($text, 0, $len, 'utf-8');
$text = utf8_trim($text) . $apip_options['excerpt_ellipsis'];
return $text;
}
开发者ID:lifishake,项目名称:apip,代码行数:25,代码来源:apip.php
注:本文中的utf8_trim函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论