Jump to content

Using PHP to convert whitespace to HTML


offsprg01

Recommended Posts

ok so here's the set up i'm taking entries from a db the client has provided and showing them in the web page. only problem is the client use tab and returns to format the text and we al know that won't work in html so.....

 

i need to take the white space and turn it in to html. anybody have any scripts i could use to do that? i haven't the slightest clue where to start. i've been trying google for hours now but mu goggle fu is failing me. :( any help would be appreciated.

 

here's a link to an example.

 

http://www.harwoodmarketinggroup.com/WIP/aboutGrande/pressroomdetials.php?recordID=3058&YEAR=2003&QUARTER=04

Link to comment
Share on other sites

I should also warn that text inside of pre tags will stretch page elements wide even if they have a CSS width attribute.

 

You can use PHP's wordwrap() function to get around this.

 

I've not tried it, but I would guess using the CSS overflow, or whatever it is, property might fix it as well.

Link to comment
Share on other sites

well then how do i get the bold stuff to format correctly without htmlentites()

 

sorry if this problem is trivial but i've never had this issue before so i am not used to converting preformatted text at run time.

 

so here's my thiking if htmlentites() returns <bold></bold> why doesn't the browser execute the html commands like it does if i just echo out a var that is equal to <bold>some text</bold>

Link to comment
Share on other sites

got is fixed i added this to the style sheet.

 

pre {

white-space: pre-wrap;      /* css-3 */

white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */

white-space: -pre-wrap;      /* Opera 4-6 */

white-space: -o-pre-wrap;    /* Opera 7 */

word-wrap: break-word;      /* Internet Explorer 5.5+ */

}

 

Link to comment
Share on other sites

ok so i have two new issues.

 

pre {

text-align: justify;

}

is not working on the pre tags. it's defaulting to left align. i can use

 

pre {

text-align; right;

}

 

however and it align every thing to the right. does anyone know how to make the text justify?

 

also: safari 1.3 completely ignores the word wrap. is there any work around for that? i cannot use php's wordwrap() as it is applied before the css font styling and thus make the words wrap as if they were still a fixed width font, resulting the the text only going half way across the page before it breaks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.