php-general | 2001072
Date: 07/31/01
- Next message: Richard Lynch: "[PHP] Re: calling javascript functions inside PHP"
- Previous message: Richard Lynch: "[PHP] Re: Reading from remote files"
- In reply to: Adam: "[PHP] splitting a string in half"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> I wish to split my databased string in half to be shown on 2 seperate
> columns, but also preserve whole words. Is there a function that does this
> already? Maybe a quick fix? Hopefully something that doesn't include html
> tags as part of the string to split. If it's not that specific then that's
> okay.
I suppose that this would work if it weren't for the HTML tags inside your
text:
$text = "Suppose this text was really long.";
$half_length = (int) strlen($text) / 2;
$split = wordwrap($text, $half_length, "</TD><TD>");
echo "<TABLE><TR><TD>$split</TD></TR></TABLE>";
Now, once you throw HTML tags into your string, you are in a much trickier
problem... Don't really see *any* solution for that in a general sense,
since somebody could use a tag that spans the entire text, and then you
can't break it in half at all...
-- WARNING richard <email protected> address is an endangered species -- Use ceo <email protected> Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Richard Lynch: "[PHP] Re: calling javascript functions inside PHP"
- Previous message: Richard Lynch: "[PHP] Re: Reading from remote files"
- In reply to: Adam: "[PHP] splitting a string in half"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

