Re: divide the text

From: Date: Tue, 14 Dec 2004 16:56:33 +0000
Subject: Re: divide the text
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-204311@lists.php.net to get a copy of this message
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

« previous php.general (#204311) next »