___ROCK___ Posted August 30, 2009 Share Posted August 30, 2009 <?php $my_html = htmlspecialchars("<html> <head> <title> </title> </head><body>whats up </body></html>"); echo $my_html; ?> How can I format this code so it appears like this <html> <head> <title> </title> </head> <body>whats up </body> </html> Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 30, 2009 Share Posted August 30, 2009 You'll need to use regex or str_replace to create newlines after each tag.. such as.. replacing '<head>' with '<head><br/>\n'. Quote Link to comment Share on other sites More sharing options...
.josh Posted August 30, 2009 Share Posted August 30, 2009 where is the string coming from? If you are hardcoding it like that, simply add \n after each tag (not <br/> : because you are using htmlspecialchars, it will just echo out the literal <br/>). Quote Link to comment Share on other sites More sharing options...
___ROCK___ Posted August 30, 2009 Author Share Posted August 30, 2009 I tried both examples and nothing seem to work. Quote Link to comment Share on other sites More sharing options...
___ROCK___ Posted August 30, 2009 Author Share Posted August 30, 2009 Can you guys show me a small example of what you mean on the above answers. Maybe I'm not doing it right. <?php $my_str = htmlspecialchars('<html> <head> </head </html>' ); echo $my_str; ?> how can I format that above code to look like this. <html> <title> </title> </html> Quote Link to comment Share on other sites More sharing options...
.josh Posted August 30, 2009 Share Posted August 30, 2009 seriously? "simply add \n after each tag" <html>\n<head>\n</head>\n</html>\n etc... would you like me to hold your dick for you while you pee, too? Quote Link to comment Share on other sites More sharing options...
___ROCK___ Posted August 31, 2009 Author Share Posted August 31, 2009 seriously? "simply add \n after each tag" <html>\n<head>\n</head>\n</html>\n etc... I did that but it did not work, and since you are a php guru show me something that works. would you like me to hold your dick for you while you pee, too? I don't you to hold my dick, Just open your mouth so I can pee and shit in it! Quote Link to comment Share on other sites More sharing options...
___ROCK___ Posted August 31, 2009 Author Share Posted August 31, 2009 I don't you to hold my dick, Just open your mouth so I can pee and shit in it! I don't need you to hold my dick, Just open your mouth so I can pee and shit in it! Quote Link to comment Share on other sites More sharing options...
.josh Posted August 31, 2009 Share Posted August 31, 2009 congrats. you managed to be even less mature than me. Not a task easily accomplished. Quote Link to comment Share on other sites More sharing options...
___ROCK___ Posted September 2, 2009 Author Share Posted September 2, 2009 Our childish behavior has set me off track for a bit. Now back to the main topic, I did not mention that I wanted see the formatted text. :'( Therefore what you have posted is correct, but i need to go one step further which is display the formatted code. So if i wanted to say "u r rite oh great one". i would like to have it displayed like this. <html> <title> The Grate One</title> <body> <p> You Are Right, Oh Great One! </p></body> </html> Thanks for all the php help, and for helping me relieve myself. Quote Link to comment Share on other sites More sharing options...
newbtophp Posted September 2, 2009 Share Posted September 2, 2009 Try str_replace: <?php $my_str = "<html>\n<title> The Grate One</title>\n<body>\n <p> u r Right, Oh Great One! </p>\n</body>\n</html>"; $my_str = str_replace('u', 'You', $my_str); $my_str = str_replace('r', 'Are', $my_str); highlight_string($my_str); ?> Quote Link to comment Share on other sites More sharing options...
___ROCK___ Posted September 2, 2009 Author Share Posted September 2, 2009 Mission accomplished! Great work newbtophp. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.