jaymc Posted April 29, 2007 Share Posted April 29, 2007 I have a text document which i use php to strip data from One stage it strips someones name, however, there name contains a hidden character and after further investigation ive found it to be the html eqivelent of %0D Which is apparently a line feed How can I use PHP to strip it out. Please note that its not actually displayed as THERENAME%0D But I know its there Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/ Share on other sites More sharing options...
php_joe Posted April 29, 2007 Share Posted April 29, 2007 why can't you just use str_replace()? Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-241113 Share on other sites More sharing options...
jaymc Posted April 29, 2007 Author Share Posted April 29, 2007 Because it doesnt show up as %0D in notepad or when echoing it I only found it out when it was displayed in the browser and I noticed that char appearing at the end Its like an invisible character anywhere else apart from in an address bar Or if its in notepad it will just insert a new line. I suppose its like \n How the hell can i get rid ofr this its driving me crazy Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-241142 Share on other sites More sharing options...
php_joe Posted April 29, 2007 Share Posted April 29, 2007 have you tried saving the document as UTF-8 or big unidian? Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-241148 Share on other sites More sharing options...
jaymc Posted April 29, 2007 Author Share Posted April 29, 2007 The txt file is generated from a bespoke program I need to achieve this in PHP Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-241193 Share on other sites More sharing options...
AndyB Posted April 30, 2007 Share Posted April 30, 2007 Try ereg_replace -> http://ca.php.net/function.ereg-replace even has an example for you in the user notes on replacing %0D Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-241276 Share on other sites More sharing options...
jaymc Posted April 30, 2007 Author Share Posted April 30, 2007 That doesnt work Its not physically visible when echoed out or even in a database Its like a hidden char which only has relivence in a browser URL or as a line break Therefor doin an str_replace or ereg_replace wont detect it Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-241947 Share on other sites More sharing options...
jaymc Posted May 1, 2007 Author Share Posted May 1, 2007 Does PHP treat text as binary? Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-241996 Share on other sites More sharing options...
Guest prozente Posted May 1, 2007 Share Posted May 1, 2007 It's not a linefeed, it's a carriage return, in PHP it's \r Use str_replace So you'd put for "\r" to be replaced with '' which would be nothing Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-242189 Share on other sites More sharing options...
MadTechie Posted May 1, 2007 Share Posted May 1, 2007 if its always at the end, use trim(), i had the same problem, (a CR at the end lines) TRIM resolved it, shout and simple Quote Link to comment https://forums.phpfreaks.com/topic/49202-solved-html-char-0d/#findComment-242331 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.