Re: divide the text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ahmed Abdel-Aliem wrote:
> hi,
> i have a page that views details of games from a database
> i get the text and screen shots from the database,
> i want to view 3 pictures among the text when i view it
> how i can view the 1st picture after 1/3 of the text and the next one
> after 2/3 of the text without affecting the text itself

There might be some fancy CSS way to do this...

But a crude way to do it, which should work with just about every browser,
would be:

<?php
$text = "Your long text from the database here.";
$width = round(strlen($text)/3);
$delimiter = 'AN EXTREMELY UNLIKELY STRING TO BE EMBEDDED IN YOUR TEXT';
//Let PHP handle breaking things on a word/space basis:
$wrapped = wordwrap($text, $width, $delimiter);
$parts = explode($delimiter, $wrapped);
?>
<TABLE><TR>
  <TD><?=$parts[0]?><IMG ...></TD>
  <TD><?=$parts[1]?><IMG ...></TD>
  <TD><?=$parts[2], (isset($parts[3])?$parts[3]:'')?><IMG ...></TD>
</TR></TABLE>

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux