User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Aug 2003
Location: Steamboat Springs, CO
Posts: 82
Reputation: himerus is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 0
himerus's Avatar
himerus himerus is offline Offline
Junior Poster in Training

How to do a more... link

  #1  
Nov 16th, 2003
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.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 1:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC