Re: string formatting help
| From: | Steve Edberg | Date: | Fri, 06 Jul 2001 20:28:51 +0000 |
| Subject: | Re: string formatting help | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56571@lists.php.net to get a copy of this message | ||
In the original message below, did you mean that you're actually SEEING the <br> tags in the output? If so, there may be a conversion with htmlentities() going on somewhere that converts the <br> tags to <br> (so they are displayed instead of being interpreted).
If you replaced the <br>'s with spaces or newlines, the output _should_ all be on one line, since HTML considers ALL strings of whitespace (tabs, newlines, returns, spaces) to be a single space. If you replaced <br>'s with newlines and you are getting the line breaks still, your output may be in a <pre>...</pre> block.
- steve
At 3:36 PM -0300 7/6/01, "InÈrcia Sensorial" <inerte@hotmail.com> wrote:
Maybe: $array = explode("<br>", $string); foreach ($array as $key => $value) {Or, more compactly: echo str_replace('<br>', '', $string); This would only work if tags were lowercased; to handle mixed case, you'd need to do echo eregi_replace('<br>', '', $string); or use the preg equivalentecho "$value";} Would separate the string by <br>'s and print all in one line.
Julio Nobrega. A hora est· chegando: http://sourceforge.net/projects/toca "Chad Day" <cday@atpco.com> wrote in message news:NFBBLNJBKLPPMKEJAKCOEEJNCHAA.cday@atpco.com...-- +------ Factoid: Of the 100 largest economies in the world, 51 are ------+ | Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +--- corporations ------ http://www.ips-dc.org/reports/top200text.htm ---+I'm trying to pull a string from a database to use in a javascript function.. but it's doing line breaks on me, which in turn messes up the javascript. The string in the mysql db is like: kjdsakjadk<br>skjdks<br><br>kjkdfjdfkjfd When I pull it out, it becomes: kjdsakjadk <br> skjdks <br> <br> kjkdfjdfkjfd I've tried replacing the br's with blank spaces or new line characters,butin the html code it still breaks on those breaks when I echo it back out. How can I force this string to be all on one line? Thanks,Chad