Jump to content


Photo

Splitting up text called from database


  • Please log in to reply
2 replies to this topic

#1 Mr Chris

Mr Chris
  • Members
  • PipPipPip
  • Advanced Member
  • 336 posts

Posted 14 July 2006 - 09:35 AM

Hi Guys,

Say I’m pulling a record out of my database and have 350 words (as an example) as the body_text .  I’d usually just do this:

<?php  echo nl2br($body_text); ?>

But, what I want to do is split the text up.  So I can wrap a picture around the text at the start of the text.  Then again somewhere in the middle I could wrap a quote box around the text like they have done on the BBC site:

http://news.bbc.co.u...aly/5177140.stm

Now I was recommended to do this I should look at the function substr

But it seems you have to know the amount of words that you will use using this function as shown:

http://www.w3schools...ring_substr.asp

So can anyone offer me any advise on how I can do this?

Many Thanks

Chris

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 14 July 2006 - 09:41 AM

Wouldn't it be easier to position all of the elements with CSS and have the text auto-wrap around them?

#3 Mr Chris

Mr Chris
  • Members
  • PipPipPip
  • Advanced Member
  • 336 posts

Posted 14 July 2006 - 10:00 AM

Thanks, but I don't understand how i'd do this as surely if I just echo:

<?php  echo nl2br($body_text); ?>

That will just output all the text and any positioned DIV's will not wrap around the outputted text?

Thanks

Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users