The Little Guy Posted December 7, 2006 Share Posted December 7, 2006 When I get contents of a file, there is a lot of white space, and it is saved to the database. How can I remove it and replace it with a single space?Here is an example of how it is saved:[code] Home Sign Up FAQ Imprint Contact LinkUs Topliste Vote Webmasterlinks Werbung buchen Login Login Name: PW: Password Lost Stats Stats 17262 Members Anmeldungen heute: 4 Anmeldungen gestern: 1 Welcome!Get 255 MB Webspace, a Subdomain and E-Mail forwarding ([email protected]) for free!Erotic and Commercial Content is also allowed. Domain-Check Enter your desired Domain-Name:www.speedsurf.to/ Sign Up now and get started in less than a Minute! online-advertisingSurftips:free-traffic website-trafficmodeautosurf wholesaletrafficwebsite-promotion privat-krankenversicherung vorsorge webspace free-web-space autohitsauto-hits werbung versicherungs-vergleich free-templates bannertausch sponsor cashmail webmarketingaktionsangebote kostenloses kunst gemaeldegalerievhs-digitalisierenfragezeichenmehr-besucher scream 0.024 Sekunden (6 Mysql Querys) @ Version: 2.8.5 [/code] Link to comment https://forums.phpfreaks.com/topic/29851-remove-white-space/ Share on other sites More sharing options...
The Little Guy Posted December 7, 2006 Author Share Posted December 7, 2006 I think this will do it, but I will have to try later.Please let me know, if I'm wrong...[code]<?php$str = 'foo o';$str = preg_replace('/\s\s+/', ' ', $str);// This will be 'foo o' nowecho $str;?> [/code] Link to comment https://forums.phpfreaks.com/topic/29851-remove-white-space/#findComment-137144 Share on other sites More sharing options...
papaface Posted December 7, 2006 Share Posted December 7, 2006 [code]preg_replace('/[\s]/', ' ', $str);[/code]That should do it. Link to comment https://forums.phpfreaks.com/topic/29851-remove-white-space/#findComment-137147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.