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


PHP _substr函数代码示例

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


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

示例1: test_strings

 public function test_strings()
 {
     $sentence = 'пользователь должен быть у Вас в друзьях а Вы у него';
     $testcase = ['tHe QUIcK bRoWn' => 'QUI', 'frànçAIS' => 'çAI', 'über-åwesome' => '-åw'];
     foreach ((array) $testcase as $input => $output) {
         $this->assertEquals(_substr($input, 4, 3), $output);
     }
     $this->assertEquals(_truncate($sentence, 10), 'пользовате');
     $this->assertEquals(_truncate($sentence, 15, true), 'пользователь');
     $this->assertEquals(_truncate($sentence, 15, true, true), 'пользовател...');
 }
开发者ID:yfix,项目名称:yf,代码行数:11,代码来源:class_utf8.Test.php

示例2: tagparam2array

/**
 * HTMLタグのパラメータを配列に変換する
 *
 * @param string	$param	「name1="value1" name2="value2" ...」形式の文字列
 * @return array	連想配列
 */
function tagparam2array($param)
{
    $ret = array();
    while ($param != '' && mb_ereg('^.*?([^\\t  ]+?)=(?:(\'|")(.*?)\\2|([^\\t  \'"][^\\t  ]*))', $param, $m)) {
        $ret[$m[1]] = $m[3] . $m[4];
        //$m[3]と$m[4]のどちらかは空文字列なので、これでヒットしたほうを取得できる
        $param = _substr($param, strlen($m[0]));
    }
    return $ret;
}
开发者ID:riaf,项目名称:kinowiki,代码行数:16,代码来源:func.inc.php

示例3: getChunkedAnnotation

 function getChunkedAnnotation()
 {
     if (!$this->loaded) {
         $this->load();
     }
     return array('short' => $short = close_dangling_tags(trim(_substr($this->data['description'], 400))), 'html' => $this->data['description']);
 }
开发者ID:rasstroen,项目名称:metro,代码行数:7,代码来源:Book.php

示例4: processBio

 function processBio($fullHtml)
 {
     $body = '';
     $short = '';
     $body = strip_tags($fullHtml, '<p><strong><i><em><b>');
     $body = str_replace('<strong>', '<b>', $body);
     $body = str_replace('</strong>', '</b>', $body);
     $body = str_replace('<i>', '<em>', $body);
     $body = str_replace('</i>', '</em>', $body);
     $short = close_dangling_tags(trim(_substr($body, 900)));
     return array($body, $short);
 }
开发者ID:rasstroen,项目名称:metro,代码行数:12,代码来源:Person.php

示例5: substr

 public static function substr($str, $offset, $length = NULL)
 {
     if (UTF8::$server_utf8) {
         return $length === NULL ? mb_substr($str, $offset, mb_strlen($str), JsonApiApplication::$charset) : mb_substr($str, $offset, $length, JsonApiApplication::$charset);
     }
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require JsonApiApplication::find_file("utf8", __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = TRUE;
     }
     return _substr($str, $offset, $length);
 }
开发者ID:benshez,项目名称:DreamWeddingCeremonies,代码行数:12,代码来源:UTF8.php

示例6: foreach

$__view__data__0__ = $data;
if (is_array($__view__data__0__)) {
    foreach ($__view__data__0__ as $list) {
        ?>
	<tr>
		<td align="left">&nbsp;<?php 
        echo $list[VariableName];
        ?>
</td>
		<td>&nbsp;<?php 
        echo $list[VariableDescribe];
        ?>
</td>
		<td align="left"><?php 
        if ($list[VariableType] == 0) {
            echo _substr($list[VariableValue], 80);
        } else {
            ?>
(数组数据不提供预览)<?php 
        }
        ?>
</td>
		<td align="left">&nbsp; <a
			href="<?php 
        echo UrlRewriteSimple('GlobalCfgs', 'Lists', true);
        ?>
&VariableName=<?php 
        echo $list[VariableName];
        ?>
">修改</a>
		&nbsp; | &nbsp;<a href="javascript:;"
开发者ID:baiduXM,项目名称:agent,代码行数:31,代码来源:GlobalCfgsLists.tpl.php

示例7: the_post_thumbnail

            echo '" class="thumbnail-wrapper">';
            the_post_thumbnail();
            echo '</a>';
        } else {
            echo '<a href="';
            the_permalink();
            echo '" class="thumbnail-wrapper">';
            echo '<img src="';
            echo catch_that_image();
            echo '" alt="" />';
            echo '</a>';
        }
        ?>
											</div>
											<?php 
        echo _substr(wp_trim_excerpt(), 300, get_permalink());
        ?>
											<div><a class="more-link" href="<?php 
        the_permalink();
        ?>
"> Nhấn vào để đọc thêm</a></div>
										<div class="clearFix"></div>
									</div>
									</div>
									<div class="subFooting">
									<div class="tags-and-categories">
										<?php 
        the_tags();
        ?>
			
									</div>
开发者ID:nstungxd,项目名称:F2CA5,代码行数:31,代码来源:index.php

示例8: substr

 /**
  * Returns part of a UTF-8 string
  *
  * This is a UTF8-aware version of [substr](http://php.net/substr).
  *
  * Example:
  * ~~~
  * $sub = UTF8::substr($str, $offset);
  * ~~~
  *
  * @author  Chris Smith <chris@jalakai.co.uk>
  *
  * @param   string   $str     Input string
  * @param   integer  $offset  Offset
  * @param   integer  $length  Length limit [Optional]
  *
  * @return  string
  *
  * @uses    UTF8::$server_utf8
  * @uses    Kohana::$charset
  * @uses    Kohana::find_file
  */
 public static function substr($str, $offset, $length = NULL)
 {
     if (self::$server_utf8) {
         return is_null($length) ? mb_substr($str, $offset, mb_strlen($str), Kohana::$charset) : mb_substr($str, $offset, $length, Kohana::$charset);
     }
     UTF8::_load(__FUNCTION__);
     return _substr($str, $offset, $length);
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:30,代码来源:utf8.php

示例9: viewcat

function viewcat($array_subcat, $array_cat, $items)
{
    global $module_info, $global_array_cat, $global_config, $module_name, $module_file, $lang_module, $numsubcat, $showcatimage, $numinsub;
    $xtpl = new XTemplate("viewcat.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . "/modules/" . $module_file);
    $xtpl->assign('LANG', $lang_module);
    $width = round(100 / $numsubcat, 0);
    $xtpl->assign("W", $width);
    foreach ($array_cat as $array_cat_i) {
        $xtpl->assign('CAT', $array_cat_i);
        if (!empty($array_cat_i['description'])) {
            $xtpl->parse('main.cat.showdes');
        }
        $xtpl->parse('main.cat');
    }
    if (!empty($array_subcat)) {
        $a = 1;
        foreach ($array_subcat as $array_subcat_i) {
            $xtpl->assign('SUB', $array_subcat_i);
            if ($showcatimage == 1 and !empty($array_subcat_i['catimage'])) {
                if (file_exists(NV_UPLOADS_REAL_DIR . NV_UPLOADS_DIR . "/" . $array_subcat_i['catimage']) && $array_subcat_i['catimage'] != "") {
                    $xtpl->assign("IMG", "" . NV_BASE_SITEURL . "/" . $array_subcat_i['catimage'] . "");
                }
            } else {
                $xtpl->assign("IMG", "" . NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/" . $module_file . "/no_image.gif");
            }
            $numinsub == 1 ? $xtpl->parse('main.sub.loop.count_link') : "";
            $xtpl->assign("FLOAT", $a % $numsubcat == false ? "fr" : "fl");
            $a % $numsubcat == false ? $xtpl->parse('main.sub.loop.clear') : "";
            $xtpl->parse('main.sub.loop');
            $a++;
        }
        $xtpl->parse('main.sub');
    }
    if (!empty($items)) {
        foreach ($items as $items_i) {
            $items_i['add_time'] = nv_date("H:i l - d/m/Y", $items_i['add_time']);
            $items_i['description'] = strip_tags($items_i['description']);
            $items_i['description'] = _substr($items_i['description'], 200);
            if (!empty($items_i['urlimg'])) {
                if (!nv_is_url($items_i['urlimg'])) {
                    $items_i['urlimg'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $items_i['urlimg'];
                }
                $xtpl->assign('IMG', $items_i['urlimg']);
            } else {
                $xtpl->assign('IMG', "" . NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/" . $module_file . "/no_image.gif");
            }
            $items_i['url'] = nv_clean60($items_i['url'], 70) . "...";
            $xtpl->assign('ITEM', $items_i);
            if (defined('NV_IS_ADMIN')) {
                $xtpl->assign('ADMIN_LINK', adminlink($items_i['id']));
            }
            $xtpl->parse('main.items.loop');
        }
        $xtpl->parse('main.items');
    }
    $xtpl->parse('main');
    return $xtpl->text('main');
}
开发者ID:syphuonglam,项目名称:creative-portal,代码行数:58,代码来源:theme.php

示例10: getTextBetweenTags

function getTextBetweenTags($text, $tag)
{
    $StartTag = "<{$tag}";
    $EndTag = "</{$tag}";
    $StartPosTemp = _strpos($text, $StartTag);
    $StartPos = _strpos($text, '>', $StartPosTemp);
    $StartPos = $StartPos + 1;
    $EndPos = _strpos($text, $EndTag);
    $StartAttr = $StartPosTemp + _strlen($StartTag) + 1;
    $EndAttr = $StartPos;
    if ($EndAttr > $StartAttr) {
        $attribute = _substr($text, $StartAttr, $EndAttr - $StartAttr - 1);
        $datas = explode(' ', $attribute);
        for ($i = 0; $i < sizeof($datas); $i++) {
            if (preg_match('/^([a-zA-Z:]+)=["\'](.*)["\']/', $datas[$i], $match)) {
                $items[$match[1]] = $match[2];
            }
        }
    }
    $text = _substr($text, $StartPos, $EndPos - $StartPos);
    if (_strpos($text, '[CDATA[') == false) {
        $text = str_replace('&lt;', '<', $text);
        $text = str_replace('&gt;', '>', $text);
        $text = str_replace('&amp;', '&', $text);
        $text = str_replace('&quot;', '"', $text);
    } else {
        $text = str_replace('<![CDATA[', '', $text);
        $text = str_replace(']]>', '', $text);
    }
    $items['data'] = trim($text);
    return $items;
}
开发者ID:phannack,项目名称:GCMS,代码行数:32,代码来源:reader.php

示例11: substr

 /**
  * Returns part of a UTF-8 string. This is a UTF8-aware version
  * of [substr](http://php.net/substr).
  *
  *     $sub = UTF8::substr($str, $offset);
  *
  * @author  Chris Smith <chris@jalakai.co.uk>
  * @param   string  $str    input string
  * @param   integer $offset offset
  * @param   integer $length length limit
  * @return  string
  * @uses    UTF8::$server_utf8
  * @uses    Kohana::$charset
  */
 public static function substr($str, $offset, $length = NULL)
 {
     if (UTF8::$server_utf8) {
         return $length === NULL ? mb_substr($str, $offset, mb_strlen($str), Kohana::$charset) : mb_substr($str, $offset, $length, Kohana::$charset);
     }
     if (!isset(self::$called[__FUNCTION__])) {
         require Kohana::find_file('utf8', __FUNCTION__);
         // Function has been called
         self::$called[__FUNCTION__] = TRUE;
     }
     return _substr($str, $offset, $length);
 }
开发者ID:BenjaminRomeo,项目名称:KohanaTest,代码行数:26,代码来源:UTF8.php

示例12: get_the_content_with_formatting

function get_the_content_with_formatting($more_link_text = 'Read more', $stripteaser = 0, $more_file = '')
{
    global $data;
    if ($data['wm_blog_words_count'] > 0) {
        $word_cnt = $data['wm_blog_words_count'];
    } else {
        $word_cnt = 600;
    }
    $content = get_the_content('', $stripteaser, $more_file);
    $content = strip_shortcodes($content);
    $content = str_replace(']]>', ']]&gt;', $content);
    $content = '<p>' . _substr(strip_tags($content), $word_cnt) . '</p>';
    $content .= '<a class="read_more" href="' . get_permalink() . '" title="' . get_the_title() . '">' . $more_link_text . '</a><!-- Read more link -->';
    return $content;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:15,代码来源:custom.lib.php

示例13: get_the_content_with_formatting

function get_the_content_with_formatting($chars = 560, $stripteaser = 0, $more_file = '')
{
    $content = get_the_content('', $stripteaser, $more_file);
    $content = strip_shortcodes($content);
    $content = str_replace(']]>', ']]&gt;', $content);
    $content = _substr(strip_tags(strip_shortcodes($content)), $chars);
    $content .= '<br/><br/><a href="' . get_the_permalink() . '">' . _e('Continue Reading', THEMEDOMAIN) . '</a><br/><br/>';
    return $content;
}
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:9,代码来源:custom.lib.php

示例14: mysql_query

 * 		Latest Ban
 *
 */
$latest_ban = mysql_query("SELECT player_id, player_nick, ban_reason, ban_created, ban_length, ban_type FROM " . $config->db_prefix . "_bans ORDER BY ban_created DESC LIMIT 1") or die(mysql_error());
while ($lb = mysql_fetch_object($latest_ban)) {
    if ($lb->ban_length == 0) {
        $ban_length = 0;
    } else {
        $ban_length = $lb->ban_created + $lb->ban_length * 60;
    }
    if ($lb->ban_type == "SI") {
        $steamid = "SI";
    } else {
        $steamid = $lb->player_id;
    }
    $last_ban_arr = array("steamid" => $steamid, "nickname" => htmlspecialchars(_substr($lb->player_nick, 15)), "reason" => htmlspecialchars(_substr($lb->ban_reason, 15)), "created" => $lb->ban_created, "length" => $ban_length, "time" => time());
}
/*
 *
 * 		Template parsing
 *
 */
// Header
$title = "_TITLEVIEW";
// Section
$section = "live";
// Parsing
$smarty = new dynamicPage();
$smarty->assign("meta", "");
$smarty->assign("title", $title);
$smarty->assign("section", $section);
开发者ID:GoeGaming,项目名称:bans.sevenelevenclan.org,代码行数:31,代码来源:view.php

示例15: start

 public static function start(array $controllers = [], $fn = '')
 {
     $requestUri = self::$_env['request_uri'];
     self::$_env['request_method'] = self::getServer('REQUEST_METHOD', 'GET');
     // 自定义的 控制器
     foreach ($controllers as $controller) {
         if (!_startWith($requestUri, '/' . $controller)) {
             continue;
         }
         if ($requestUri == '/' . $controller) {
             self::$_env['controller'] = $controller;
             self::$_env['action'] = 'index';
             //加载初始化文件
             $initFile = self::$_env['controllersDir'] . '/' . $controller . '/__init__.php';
             if (file_exists($initFile)) {
                 include_once $initFile;
             }
             //加载自定义
             self::__loadControllerAction(self::$_env['controller'], $fn);
         } else {
             if ($_actionUri = _substr($requestUri, $controller)) {
                 $_action_uri = explode('/', $_actionUri, 3);
                 if (sizeof($_action_uri) == 2 && !file_exists(self::$_env['controllersDir'] . '/' . $controller . '/' . $_action_uri[1] . '.php')) {
                     self::$_env['controller'] = $controller . '/index';
                     self::$_env['action'] = self::getArrayValue($_action_uri, 1, 'index');
                 } else {
                     self::$_env['controller'] = $controller . '/' . self::getArrayValue($_action_uri, 1, 'index');
                     self::$_env['action'] = self::getArrayValue($_action_uri, 2, 'index');
                 }
                 //加载初始化文件
                 $initFile = self::$_env['controllersDir'] . '/' . $controller . '/__init__.php';
                 if (file_exists($initFile)) {
                     include_once $initFile;
                 }
                 //加载自定义
                 self::__loadControllerAction(self::$_env['controller'], $fn);
             }
         }
     }
     //-- end
     $_requestUri = explode('/', $requestUri, 3);
     self::$_env['controller'] = self::getArrayValue($_requestUri, 1, 'index');
     self::$_env['action'] = self::getArrayValue($_requestUri, 2, 'index');
     self::__loadControllerAction(self::$_env['controller'], $fn);
 }
开发者ID:sdgdsffdsfff,项目名称:marvel,代码行数:45,代码来源:X.php


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