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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.