Linked Questions

15 votes
9 answers
42k views

I'm pulling blog posts from a DB. I want to trim the text to a max length of 340 characters. If the blog post is over 340 characters I want to trim the text to the last full word and add '...' on ...
CLiown's user avatar
  • 13.9k
9 votes
1 answer
5k views

Possible Duplicate: Truncate a multibyte String to n chars Hello, I'm developing a site in French and I created a function that cuts string after X number of characters. It works great, but when ...
denislexic's user avatar
  • 11.5k
1 vote
1 answer
2k views

Possible Duplicate: Truncate a multibyte String to n chars Hye guys, So here's what I need to do. I want dots to appears after a sentence crosses a certain number of words in PHP. Ex - This is a ...
sarthak's user avatar
  • 11
0 votes
2 answers
1k views

I want to print specific word character in specific Line (do something like a word wrap) Suppose I have 40 Character. My Name Is Johnty and i am eating an Nut and my length for character is 20. So ...
Sachin Sanchaniya's user avatar
0 votes
2 answers
374 views

Possible Duplicates: Truncate a multibyte String to n chars How to Truncate a string in PHP to the word closest to a certain number of characters? eg: PHP is a widely-used general-purpose ...
zhuanzhou's user avatar
  • 2,435
0 votes
2 answers
182 views

I have this code for parsing RSS to HTML. <?php $channel_desc = $channel->getElementsByTagName('description') ->item(0) ->childNodes ...
Dimas Lanjaka's user avatar
-1 votes
2 answers
71 views

I am calling all names from a mysql database using php. Some names are very large. so i want to show first 7 charectors and put "..." Here is my code: <?php $result = mysql_query("SELECT * FROM ...
alon1234's user avatar
  • 117
-5 votes
1 answer
48 views

I have the following code: <!DOCTYPE html> <html> <head> <title>E6 L7</title> <meta charset="utf-8"> </head> <body> ...
Luciano's user avatar
393 votes
21 answers
553k views

How can I get the first n characters of a string in PHP? What's the fastest way to trim a string to a specific number of characters, and append '...' if needed?
Alex's user avatar
  • 66.6k
205 votes
28 answers
212k views

I have a code snippet written in PHP that pulls a block of text from a database and sends it out to a widget on a webpage. The original block of text can be a lengthy article or a short sentence or ...
Brian's user avatar
  • 2,061
112 votes
6 answers
228k views

I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing. Is there a function that can do this easily? For example: $string1 = "I am ...
JoshFinnie's user avatar
  • 4,921
68 votes
11 answers
101k views

I know how to use the substr function but this will happy end a string halfway through a word. I want the string to end at the end of a word how would I go about doing this? Would it involve regular ...
Cool Hand Luke's user avatar
14 votes
13 answers
19k views

I have the following string in a variable. Stack Overflow is as frictionless and painless to use as we could make it. I want to fetch first 28 characters from the above line, so normally if I use ...
djmzfKnm's user avatar
  • 27.3k
24 votes
3 answers
131k views

I'm trying to truncate some text in PHP and have stumbled across this method (http://theodin.co.uk/blog/development/truncate-text-in-php-the-easy-way.html), which judging by the comments seems like a ...
realph's user avatar
  • 4,711
13 votes
9 answers
35k views

My variable $content contains my text. I want to create an excerpt from $content and display the first sentence and if the sentence is shorter than 15 characters, I would like to display the second ...
anonymous's user avatar
  • 1,549

15 30 50 per page