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


PHP Str::truncate方法代码示例

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


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

示例1: test_truncate

 /**
  * Test for Str::truncate()
  * 
  * @test
  */
 public function test_truncate()
 {
     $limit = 15;
     $string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
     $output = Str::truncate($string, $limit);
     $expected = 'Lorem ipsum dol...';
     $this->assertEquals($expected, $output);
     $output = Str::truncate($string, $limit, '..');
     $expected = 'Lorem ipsum dol..';
     $this->assertEquals($expected, $output);
     $string = '<h1>' . $string . '</h1>';
     $output = Str::truncate($string, $limit, '...', false);
     $expected = '<h1>Lorem ipsum...';
     $this->assertEquals($expected, $output);
     $output = Str::truncate($string, $limit, '...', true);
     $expected = '<h1>Lorem ipsum dol...</h1>';
     $this->assertEquals($expected, $output);
 }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:23,代码来源:str.php

示例2: test_truncate_multiple_tags

 /**
  * Test for Str::truncate()
  *
  * @test
  * @dataProvider truncate_provider
  */
 public function test_truncate_multiple_tags($limit, $string)
 {
     $limit = 400;
     $string = '<p><strong>' . $string . '</strong></p>';
     $output = Str::truncate($string, $limit, '...', true);
     $this->assertEquals($string, $output);
 }
开发者ID:takawasitobi,项目名称:pembit,代码行数:13,代码来源:str.php

示例3:

									<a href="#" class="clearfix">
										<img src="<?php 
        echo $value->from->people->photo;
        ?>
" class="msg-photo" alt="<?php 
        echo $value->from->people->nickname;
        ?>
 Avatar" />
										<span class="msg-body">
											<span class="msg-title">
												<span class="blue"><?php 
        echo $value->from->people->nickname;
        ?>
:</span>
												<?php 
        echo \Str::truncate($value->body, 0, 21, '...');
        ?>
											</span>

											<span class="msg-time">
												<i class="ace-icon fa fa-clock-o"></i>
												<span><?php 
        echo \Date::time_ago($value->created_at);
        ?>
</span>
											</span>
										</span>
									</a>
								</li>
								<?php 
    }
开发者ID:wxl2012,项目名称:wx,代码行数:31,代码来源:nav.php

示例4: date

</span>
                                                <p><?php 
echo date('d', $date);
?>
</p>
                                        </div>
                                        <div class="events__title">
                                            <h5>
                                                <? if(\Arr::get($config, 'link')) :?>
                                                <a href="<?php 
echo \Arr::get($config, 'link') . '?month=' . date('M', $date) . '#' . $event->id;
?>
">
                                                <? endif;?>
                                                <?php 
echo \Str::truncate($event->name, 30, '...');
?>
                                                <? if(\Arr::get($config, 'link')) :?>
                                                </a>
                                                <? endif;?>
                                            </h5>
                                        </div>                                    
                                    </div>                                

                                </a>

                                <? $i++;?>    

                            <? endif ?>

                        
开发者ID:propcom,项目名称:R7-sections,代码行数:29,代码来源:events.php

示例5: __

?>
</h1>
    <p>
    	<small>
			<?php 
echo __('by');
?>
 <a href="<?php 
echo \Router::get('show_post_author', array('author' => $post->user->username));
?>
">
                <?php 
echo $post->user->username;
?>
</a> <?php 
echo __('on');
?>
 <em><?php 
echo date('d/m/Y', $post->created_at);
?>
</em>
		 </small>
	 </p>
    </div>

    <graph></graph>
    <?php 
echo $snippet == true ? \Str::truncate(\Markdown::parse($post->content), \Config::get('application.truncate', 400)) : \Markdown::parse($post->content);
?>

</article>
开发者ID:daniel-rodas,项目名称:rodasnet.com,代码行数:31,代码来源:show.php

示例6: array

        ?>
" >
            <small>
                <a href="<?php 
        echo \Router::get('show_post_category', array('category' => $post->category->slug));
        ?>
"><?php 
        echo $post->category->name;
        ?>
</a>

            </small>
            <a href="<?php 
        echo \Router::get('show_post', array('segment' => $post->slug));
        ?>
" >

                <h2 class=""><?php 
        echo \Str::truncate($post->name, \Config::get('application.truncate', 50));
        ?>
</h2>
            </a>
        </article>


    <?php 
    }
    ?>
    </div>
<?php 
}
开发者ID:daniel-rodas,项目名称:rodasnet.com,代码行数:31,代码来源:related.php

示例7: if

echo \Arr::get($region, 'title');
?>
" class="scale-with-grid">

					<h5><?php 
echo \Arr::get($region, 'title', 'Default');
?>
</h5>

					<? $content = \Arr::get( $region, 'content', 'Default content, please add your own.' ); ?>

					<? if ( is_string ( $content ) ) : ?>

						<p>
							<?php 
echo \Str::truncate($content, 200, '...');
?>
						</p>

					<? elseif ( is_array ( $content ) ) : ?>

						<? foreach ( $content as $line ) : ?>

							<p>
								<?php 
echo $line;
?>
							</p>

						<? endforeach; ?>
开发者ID:propcom,项目名称:R7-sections,代码行数:30,代码来源:cta.php

示例8:

            $thumbnail = '/assets/web/images/01.jpg';
            $title = '';
            if (in_array($item->order_type, ['SELL', 'GROUPBUY'])) {
                $thumbnail = $detail->goods->thumbnail;
                $title = $detail->goods->title;
            } else {
                if ($item->order_type == 'MARKET') {
                    $thumbnail = $detail->market->thumbnail;
                    $title = $detail->market->title ? $detail->market->title : $detail->goods->title;
                } else {
                    if ($item->order_type == 'RESERVE') {
                        $title = "{$detail->table->name}({$detail->seat->name})";
                    }
                }
            }
            $title = \Str::truncate($title, 25, '...');
            ?>
                            <img src="<?php 
            echo $thumbnail;
            ?>
" alt="" style="width: 100%;">
                        </div>
                        <div class="col-xs-8" style="border-bottom: 1px solid #efefef;">
                            <p style=" padding-top: 10px;"><?php 
            echo $title;
            ?>
</p>
                            <?php 
            if ($item->order_type == 'MARKET') {
                ?>
                                <p style=" height: 50px; overflow: auto;">夺宝号码:<?php 
开发者ID:wxl2012,项目名称:wx,代码行数:31,代码来源:pay_records.php

示例9: array

<article class="post featured-story">

    <a href="<?php 
echo \Router::get('show_post', array('segment' => $post->slug));
?>
">
        <h1><?php 
echo $post->name;
?>
</h1>
        <img class="img-responsive" src="<?php 
echo $featured_image;
?>
" alt=""/>

        <p>
            <?php 
echo \Str::truncate($post->content, 400, ' <span class="primary-text">&hellip;continue reading</span>');
?>
        </p>
    </a>

</article>

开发者ID:daniel-rodas,项目名称:rodasnet.com,代码行数:23,代码来源:featured.php

示例10: foreach

	<?php 
    foreach ($items as $item) {
        ?>
	<div class="sort-wrapper">
		<label class="sort-check">
		<?php 
        echo \Form::checkbox('ids[]', $item->id);
        ?>
		</label>
		<div class="aucid"><?php 
        echo $item->auc_id;
        ?>
</div>
		<div class="title"><?php 
        echo Str::truncate($item->title, 25);
        ?>
</div>
		<div class="price"><?php 
        echo $item->price;
        ?>
</div>
		<div class="date"><?php 
        echo Date::create_from_string($item->won_date, 'mysql')->format('display_date');
        ?>
</div>
		<div class="vendor"><?php 
        echo $item->vendor->name;
        ?>
</div>
		<div class="action">
开发者ID:notfoundsam,项目名称:yahooauc,代码行数:30,代码来源:index.php

示例11:

        ?>
                <div class="list-group-item">
                    <div class="row">
                        <div class="col-xs-4" style="padding-left: 2px; padding-right: 0px;">
                            <img src="<?php 
        echo $detail->goods->thumbnail;
        ?>
" alt="<?php 
        echo $detail->goods->title;
        ?>
" style="width: 100%; height: 100%;"/>
                        </div>
                        <div class="col-xs-8">
                            <dl style="margin-top: 0px; margin-bottom: 0px;">
                                <dt><?php 
        echo \Str::truncate($detail->goods->title, 25, '...');
        ?>
</dt>
                                <dd>数量: <?php 
        echo $detail->num;
        ?>
 <span style="padding-left: 5px">单价: <?php 
        echo $detail->price;
        ?>
</span></dd>
                            </dl>
                        </div>
                    </div>
                </div>
            <?php 
    }
开发者ID:wxl2012,项目名称:wx,代码行数:31,代码来源:index.php

示例12: testTruncate

 public function testTruncate()
 {
     $str = Str::truncate('abcdefghij', 5);
     $this->assertEquals($str, 'ab...');
 }
开发者ID:starweb,项目名称:starlit-utils,代码行数:5,代码来源:StrTest.php

示例13:

		<tr>

			<td><?php 
        echo Date::forge($item->created_at)->format('mysql');
        ?>
</td>
			<td><?php 
        echo $item->name;
        ?>
</td>
			<td><?php 
        echo $item->email;
        ?>
</td>
			<td><?php 
        echo Str::truncate($item->comment, 50, '...', true);
        ?>
</td>
			<td><?php 
        echo $item->ip_address;
        ?>
</td>
			<td>
				<?php 
        echo Html::anchor('admin/form/view/' . $item->id, '表示');
        ?>

			</td>
		</tr>
<?php 
    }
开发者ID:sato5603,项目名称:fuelphp1st-2nd,代码行数:31,代码来源:index.php

示例14: foreach

    foreach ($posts as $post) {
        ?>
		<article id="post-<?php 
        echo $post->id;
        ?>
" class="post-preview">
		    <a href="<?php 
        echo \Router::get('show_post', array('segment' => $post->slug));
        ?>
" >
                <h2><?php 
        echo $post->name;
        ?>
</h2>
                <p><?php 
        echo \Str::truncate(\Markdown::parse($post->content), \Config::get('application.truncate', 600));
        ?>
</p>
            </a>
            <small>
                <a href="<?php 
        echo \Router::get('show_post_category', array('category' => $post->category->slug));
        ?>
"><?php 
        echo $post->category->name;
        ?>
</a>,
                <?php 
        echo __('by');
        ?>
 <a href="<?php 
开发者ID:daniel-rodas,项目名称:rodasnet.com,代码行数:31,代码来源:list.php

示例15: limit_chars

	/**
	 * Limit a text to a given characters.
	 * Alias of \Str:truncate(), with configurable parameters
	 *
	 * @access public
	 * @static
	 * @param string $str: phrase to limit characters of
	 * @param array $args (default: array()):
	 *  "length": number of characters to keep;
	 *	"trail": ommission string
	 * @return  string
	 */
	public static function limit_chars($string, $args = array())
	{
		self::extend($args, __FUNCTION__);

		return \Str::truncate($string, $args['length'], $args['trail']);
	}
开发者ID:ronan-gloo,项目名称:Fuel-Helper-Package,代码行数:18,代码来源:textHelper.php


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