•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 401,446 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,916 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2860 | Replies: 0
![]() |
| |
•
•
Join Date: Aug 2003
Location: Steamboat Springs, CO
Posts: 82
Reputation:
Rep Power: 6
Solved Threads: 0
If you are trying to do a page, or section of news that only shows a certain length of characters, and then has a link for Read Full Story, or more..., etc the following code is just what you need:
[php]
$longtext = "Full text string to be manipulated";
// I want mine to cut off text after 255 chars
$shorttext = substr($longtext,0,255);
$space = strrpos($shorttext," ");
$newtext = substr($shorttext,0,$space);
echo "$newtext <a href=more_details.php>more...</a>";[/php]
Note: I'm posting a few of these code snippets just for general reference. They are somewhat old, so please feel free to make updates, suggestions for this code. I'm posting them mainly for the benefit of newer PHP programmers.
After I get settled in, and have a little more time, I'll make updates to these next few threads, and sit down, and put together some tutorials that are more up to date.
[php]
$longtext = "Full text string to be manipulated";
// I want mine to cut off text after 255 chars
$shorttext = substr($longtext,0,255);
$space = strrpos($shorttext," ");
$newtext = substr($shorttext,0,$space);
echo "$newtext <a href=more_details.php>more...</a>";[/php]
Note: I'm posting a few of these code snippets just for general reference. They are somewhat old, so please feel free to make updates, suggestions for this code. I'm posting them mainly for the benefit of newer PHP programmers.

After I get settled in, and have a little more time, I'll make updates to these next few threads, and sit down, and put together some tutorials that are more up to date.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- IE 6 Can't open new windows from link clicked (Web Browsers)
- IE 6 Window from link won't load. (Web Browsers)
- Can IE open separate window from link? (Web Browsers)
- ie 6 Link problems (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: PHP Programmer interested in an existing project? Game! =o]
- Next Thread: Using Search Engine Friendly PHP URLs


Hybrid Mode