php arclist标签,截取字符如何在后面加上点点点
php arclist标签,截取字符怎么在后面加上点点点
初学织梦啊
那个标签
dede:arclist titlelen=42 row=12}
{/dede:arclist}
怎么使超出42长度的后面自动加上...点点点啊
------解决方案--------------------
也可以在从数据库里取title的时候,就截取
SELECT id,left(title,42) as title from table
------解决方案--------------------
------解决方案--------------------
//实现中英文截取
function cut_str($sourcestr, $cutlength = 10, $etc = '...')
{
$returnstr = '';
$i = 0;
$n = 0.0;
$str_length = strlen($sourcestr); //字符串的字节数
while ( ($n{
$temp_str = substr($sourcestr, $i, 1);
$ascnum = ord($temp_str); //得到字符串中第$i位字符的ASCII码
if ( $ascnum >= 252) //如果ASCII位高与252
{
$returnstr = $returnstr . substr($sourcestr, $i, 6); //根据UTF-8编码规范,将6个连续的字符计为单个字符
$i = $i + 6; //实际Byte计为6
$n++; //字串长度计1
}
elseif ( $ascnum >= 248 ) //如果ASCII位高与248
{
$returnstr = $returnstr . substr($sourcestr, $i, 5); //根据UTF-8编码规范,将5个连续的字符计为单个字符
$i = $i + 5; //实际Byte计为5
$n++; //字串长度计1
}
elseif ( $ascnum >= 240 ) //如果ASCII位高与240
{
$returnstr = $returnstr . substr($sourcestr, $i, 4); //根据UTF-8编码规范,将4个连续的字符计为单个字符
$i = $i + 4; //实际Byte计为4
$n++; //字串长度计1
}
elseif ( $ascnum >= 224 ) //如果ASCII位高与224
{
$returnstr = $returnstr . substr($sourcestr, $i, 3); //根据UTF-8编码规范,将3个连续的字符计为单个字符
$i = $i + 3 ; //实际Byte计为3
$n++; //字串长度计1
}
elseif ( $ascnum >= 192 ) //如果ASCII位高与192
{
$returnstr = $returnstr . substr($sourcestr, $i, 2); //根据UTF-8编码规范,将2个连续的字符计为单个字符
$i = $i + 2; //实际Byte计为2
$n++; //字串长度计1
}
elseif ( $ascnum>=65 and $ascnum{
$returnstr = $returnstr . substr($sourcestr, $i, 1);
$i = $i + 1; //实际的Byte数仍计1个
$n++; //但考虑整体美观,大写字母计成一个高位字符
}
elseif ( !(array_search($ascnum, array(37, 38, 64, 109 ,119)) === FALSE) ) //%,&,@,m,w 字符按1个字符宽
{
$returnstr = $returnstr . substr($sourcestr, $i, 1);
$i = $i + 1; //实际的Byte数仍计1个
$n++; //但考虑整体美观,这些字条计成一个高位字符
}
else //其他情况下,包括小写字母和半角标点符号
{
$returnstr = $returnstr . substr($sourcestr, $i, 1);
$i = $i + 1; //实际的Byte数计1个
$n = $n + 0.5; //其余的小写字母和半角标点等与半个高位字符宽...
}
}
if ( $i {
$returnstr = $returnstr . $etc; //超过长度时在尾处加上省略号
}
return $returnstr;
}
OR
select * from tablename substring(title,1,10) as t
------解决方案--------------------
首页上有一段代码,其实说白了就是
自己加上...,何必要程序加
- PHP code
{dede:arclist flag='h' limit='0,1'} <h2 id="a-href-Bfield-arcurl-D-field-title-a"><a href="%5Bfield:arcurl/%5D">[field:title/]</a></h2> <p>[field:description function='cn_substr(@me,110)'/]...<a href="%5Bfield:arcurl/%5D">[查看全文]</a></p> {/dede:arclist}<div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Title is the meaning that defines the title of the web page. It is located within the tag and is the text displayed in the title bar of the browser. Title is very important for the search engine optimization and user experience of the web page. When writing HTML web pages, you should pay attention to using relevant keywords and attractive descriptions to define the title element to attract more users to click and browse.

This article will explain in detail the ASCII value of the first character of the string returned by PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can gain something after reading this article. PHP returns the ASCII value of the first character of a string Introduction In PHP, getting the ASCII value of the first character of a string is a common operation that involves basic knowledge of string processing and character encoding. ASCII values are used to represent the numeric value of characters in computer systems and are critical for character comparison, data transmission and storage. The process of getting the ASCII value of the first character of a string involves the following steps: Get String: Determine the string for which you want to get the ASCII value. It can be a variable or a string constant

The title in HTML displays the title tag of the web page, which allows the viewer to know what the current page is about, so each web page should have a separate title.

This article will explain in detail how PHP returns the string from the start position to the end position of a string in another string. The editor thinks it is quite practical, so I share it with you as a reference. I hope you will finish reading this article. You can gain something from this article. Use the substr() function in PHP to extract substrings from a string. The substr() function can extract characters within a specified range from a string. The syntax is as follows: substr(string,start,length) where: string: the original string from which the substring is to be extracted. start: The index of the starting position of the substring (starting from 0). length (optional): The length of the substring. If not specified, then

Understand the substr() function in PHP for intercepting strings. In the PHP language, the substr() function is a very useful string processing function, which can be used to intercept string fragments at a specified position and length. The substr() function accepts three parameters: the string to be intercepted, the starting position of the interception, and the length of the interception. Below we will introduce the use of the substr() function in detail and give specific code examples. Basic usage of substr() function substr() function

Use the PHP function "substr" to obtain the substring of a string. In PHP programming, you often encounter situations where you need to obtain part of the content of a string. At this time, we can use PHP's built-in function "substr" to achieve this. This article explains how to use the "substr" function to get a substring of a string and provides some code examples. 1. Basic usage of the substr function The substr function is used to obtain a substring of a specified length from a string. Its basic syntax is as follows: substr(

Solutions for invalid PHPmb_substr function When developing PHP applications, the mb_substr function is often used to intercept strings. However, sometimes you may encounter situations where the mb_substr function is invalid, mainly due to character encoding issues in different environments. In order to solve this problem, we need to effectively handle the mb_substr function. A common solution is to ensure that the mb_substr function can

This article will explain in detail how PHP converts the first letter of a string to lowercase. I think it is very practical, so I share it with you as a reference. I hope you can gain something after reading this article. Converting the first letter of a PHP string to lowercase Introduction In PHP, converting the first letter of a string to lowercase is a common operation. This can be achieved by using the built-in function lcfirst() or the string operator strtolower(). This guide will dive into both approaches, providing example code and best practices. Method 1: Use the lcfirst() function The lcfirst() function is specifically designed to convert the first letter of a string to lowercase while leaving the rest of the characters unchanged. Its syntax is as follows: st
