Jump to content

wrapping images around dynamic text called from DB?


Mr Chris

Recommended Posts

Hi All,

 

Wondering if anyone can help.  I have three image paths saved into a database ($image1, $image2, $image3) and a big long text string ($the_text) which can contain anything from 800 around 1500 words.

 

Now what I want to do is wrap each image around $the_text.  IE:

 

- $image1 a one third down the page

- $image2 two thirds down the page

- $image3 outputted Last third down the page

All depending on how many characters are in the text.

 

Now the best i've come up with is outputting all three images before the text is called out like so:

 


if($image1) {
  echo '<img class="float:left;" src="'.$image1.'" alt="" />';	
}

if($image2) {
  echo '<img class="float:right;margin-top:10px;" src="'.$image2.'" alt="" />';	
}

if($image3) {
  echo '<img class="float:left;margin-top:10px;" src="'.$image1.'" alt="" />';	
}

echo '

<p class="features-text">'.str_replace("\n","</p>\r\n\t\t\t<p class=\"the-text\">",$the_text).'</p>

';

 

But this is far from ideal.

 

Anyone help me achieve the above?

 

Thanks

 

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.