dzisaacs Posted December 14, 2006 Share Posted December 14, 2006 when i echo a string i get the following result<H1>Hello</H1><P><FONT color=#ff0000>World</FONT></P>I need to convert it to<H1>Hello</H1><P><FONT color=#ff0000>World</FONT></P>Can someone help me in doing this? Link to comment https://forums.phpfreaks.com/topic/30697-string-manipulation/ Share on other sites More sharing options...
chiprivers Posted December 14, 2006 Share Posted December 14, 2006 Do you mean it is adding a line break? The <p> tag always does that, do you need you use a <p> tag? Link to comment https://forums.phpfreaks.com/topic/30697-string-manipulation/#findComment-141438 Share on other sites More sharing options...
ToonMariner Posted December 14, 2006 Share Posted December 14, 2006 I think you are referring to how this displays on the screen; i.e. you get Hello and then world on the next line. This is indeed a html issue - h1 and p tags are block level so they will clear to the next avilable line within the current element.If that is the html you are outputting then you will have to change the display properties of h1 and p in your style sheet to:h1 , p { display: inline;}That will put it on one line BUT you will not have a space between words... Link to comment https://forums.phpfreaks.com/topic/30697-string-manipulation/#findComment-141439 Share on other sites More sharing options...
dzisaacs Posted December 15, 2006 Author Share Posted December 15, 2006 // i read this variable from the DB$message = $db_Message// i pass it to a functionecho "function($message)";------in the HTML it gets displayed like thisfunction('<H1>Hello</H1><P><FONT color=#ff0000>World</FONT></P>')obviously this doesn't work for me because i need it to be like thisfunction('<H1>Hello</H1><P><FONT color=#ff0000>World</FONT></P>')i need to do some manipulation in $message = $db_Message to have the string in this way <H1>Hello</H1><P><FONT color=#ff0000>World</FONT></P>not this way<H1>Hello</H1><P><FONT color=#ff0000>World</FONT></P>any ideas? Link to comment https://forums.phpfreaks.com/topic/30697-string-manipulation/#findComment-141574 Share on other sites More sharing options...
Albright Posted December 15, 2006 Share Posted December 15, 2006 [code]<?php$message=str_replace("\n","",$message);?>[/code]That should strip out all the newline characters. Link to comment https://forums.phpfreaks.com/topic/30697-string-manipulation/#findComment-141598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.