Jump to content

How to modify my code to run HTML inline?


bjenn85

Recommended Posts

I have a simple bulletin board I'm working on and would to run all of my HTML inline for performance and/or OCD. Right now if I submit a message with multiple lines by hitting Enter and then you view the page source it breaks it up into several lines... example:

 

exphp.png

I would like it to run those <br>'s inline with the rest of the source code instead of making a new line, but I'm having trouble figuring it out. I'm using this snippet below to find Enter spaces/new lines with "\n" and then using a <br> in place:

function fixtabspa( $txt )
  {
  $srch  = array( "\n", "\t", '  ', '  ' );
  $replc = array( '<br>', '    ', '  ', '  ' );
  return str_replace( $srch, $replc, $txt );
  }

and on the posting form we call that function simply:

    $post_message = fixtabspa( $post_message );

Any clue on how to replace those \n's with <br>'s without making new lines in the source code? Thanks

Edited by bjenn85
Link to comment
Share on other sites

Hard to make sense out of what you want with the incomplete code you provided.

 

Are you viewing this code in a browser or a text editor? You say 'view source'. Does that mean you are using the browser's 'view source' command? If so, a <br> will not cause a line break (at least not in IE) so if that is the problem, then you have a \n char in the code already.

 

I'm confused as to your reason for worrying about what the 'view source' gives you for format too. Why does it matter since most people aren't going to see this? Besides - removing the <br> and inserting the \n is going to ruin the html formatting of the page.

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.