Re: Looking for a string function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jay Blanchard wrote:
[snip]
I seem to remember a built in php function that will take a huge block of
text.
Then just spit out X number of characters from it and follow it with an
additional string value.
But I cannot remember what it is.

I seem to remember it being something other than the substr().

I am looking to pull the first say 200 characters from an article and follow
the last character/word with something like ...

Does anyone know what I am talking about, or am I just smoking something and
my memory is going?
[/snip]

Usually folks roll their own as there is no set function for this.

$myShortString = substr($string, 0, 200)."...";
will work, but you're going to cutoff in the middle of some word at the end
of the substring usually.

and the fun really starts when the text contains html markup (or even bbcode, yuck)
that needs to end up as part of the 300 odd characters of text you want displayed
(a url is oftens 100+ chars long in itself but you don't want to count it
when determining the cutoff string offset.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux