Hi, I'm trying to make a news section on my home page to display text and want to find a script so that it limits the number of characters displayed but then has an option to click and display more and then expands once clicked. My first attempt at this in php so not sure where to start. Hope this is the right place to ask, was trying to use functions in PHP Please help ! thanks
Maybe something like this: $charsAllowed = 50; //Number of characters you want to limit text to $myText = "blah"; //You'd have all your text here $myTextTrimmed = substr_replace($myText, "", $charsAllowed); //Params: text to operate on, text to replace with, staring point $more = " <a href=\"location.php\">Read More</a>"; //more link $myTextTrimmed .=$more //Add the more link to the trimmed text PHP: Then you echo out $myTextTrimmed wherever you want the shortened version, and $myText wherever you want the full version. There might be a better function to trim a string to a certain length, rather than using substr_replace, I am also new to PHP so hopefully somebody can clarify this.
You would need javascript if you want to show the contents without loading. Reference you might need. Google for more.
I have a function on my site http://www.pk-tuts.co.uk/2009/string-cut-read-more/ which is what you want i believe