Jump to content

Archived

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

Mr Chris

Splitting up text called from database

Recommended Posts

Hi Guys,

Say I’m pulling a record out of my database and have 350 words (as an example) as the [b]body_text[/b] .  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.uk/sport1/hi/football/world_cup_2006/teams/italy/5177140.stm

Now I was recommended to do this I should look at the function [b] substr[/b]

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

http://www.w3schools.com/php/func_string_substr.asp

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

Many Thanks

Chris

Share this post


Link to post
Share on other sites
Wouldn't it be easier to position all of the elements with CSS and have the text auto-wrap around them?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

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.