rasta876 Posted November 1, 2008 Share Posted November 1, 2008 Hey all, When I echo something from my database as below: echo &row['sentence']; I get an output such as: Hello Todayis Monday How do I eliminate get a space between Today and is to get: Hello Today is Monday In the database the spacing is quite allright. Thanks Link to comment https://forums.phpfreaks.com/topic/130989-word-spacing-in-php/ Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 The problem is that there isn't a space in the database... you COULD add a space between all "today"s and "is"s, but that would obviously not fix any underlying problems. Link to comment https://forums.phpfreaks.com/topic/130989-word-spacing-in-php/#findComment-680044 Share on other sites More sharing options...
AndyB Posted November 1, 2008 Share Posted November 1, 2008 If your database contains "Hello Todayis Monday" then that's your problem. If your output is actually something from the database and some other words that generate "Hello Todayis Monday", give us a precise example of what you really have. Link to comment https://forums.phpfreaks.com/topic/130989-word-spacing-in-php/#findComment-680074 Share on other sites More sharing options...
hitman6003 Posted November 1, 2008 Share Posted November 1, 2008 See if your database contains any "\n" or "\r" characters. These are ignored by the browser, but depending on how you're viewing the database will show up correctly (replaced by an html line break) or as a space. echo str_replace(array("\n", "\r"), " ", $database_row['fieldname']); Link to comment https://forums.phpfreaks.com/topic/130989-word-spacing-in-php/#findComment-680280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.