Jump to content

php only return a part of a string for RSS description


wendu

Recommended Posts

hey

 

I'm trying to do RSS with PHP and currently it's working ok

 

how would I have PHP return only a part of a string that I can use in my RSS description? not just any given part, but words to a fixed point and then take one more word?

 

something line the first line of wordwrap(content, number)

What you have right there may not always work out for you.  It's an rss feed so you never know what's going to come in.  There could be really long paragraphs or something and the \n might come too far down the string.  The best way to do it would be to first premove all \n's, then wordwrap, then explode at \n' and use the first exploded element.  Alternatively, wordwrap specifying a unique delimiter and explode at that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.