PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Remove carriage return
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Remove carriage return

Réponse
 
LinkBack Outils de la discussion
Vieux 07/05/2008, 05h35   #1
bulldog8@lycos.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Remove carriage return

I have a user input form that allows them to provide a description of
their request. Unfortunately when downloading and processing the data
their carriage returns \line feeds cause problems.

It is php on a Linux machine. I've tried the following:

$comment = nl2br($comment);
$comment = str_replace("<br>"," ",$comment);

And this

$order = array("\r\n", "\n", "\r");
$replace = ' ';
$comment = str_replace($order, $replace, $comment);

And this

$comment = str_replace("\r"," ",$comment);
$comment = str_replace("\n"," ",$comment);

but the output in the file always has a '^M' where the linefeed would
be:

999~05/25/2008~05/26/2008~3~test 3 after^M
before~argh!~A


Anyone know how to cleanly remove the offending CRLF

Thanks!
Jon
  Réponse avec citation
Vieux 07/05/2008, 06h58   #2
AlmostBob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Remove carriage return

The textbox or other input form,
does not use either \n or <br>
it is text and carriage returns are represented by Ctrl-M (^M decimal
character 13 Hex 0D)
linefeeds are implied by carriage returns in many systems but are otherwise
represented by Ctrl-A (^A decimal character 10, hex 0A)
You could replace hex &#x0d, ^M, instead of \n <br> which are not present
in the data to be replaced,
the php to replace the control character is beyond me at 2 in the morning

--
Adaware http://www.lavasoft.de
spybot http://www.safer-networking.org
AVG free antivirus http://www.grisoft.com
Etrust/Vet/CA.online Antivirus scan
http://www3.ca.com/securityadvisor/virusinfo/scan.aspx
Panda online AntiVirus scan http://www.pandasoftware.com/ActiveScan/
Catalog of removal tools (1)
http://www.pandasoftware.com/download/utilities/
Catalog of removal tools (2)
http://www3.ca.com/securityadvisor/n...aspx?CID=40387
Blocking Unwanted Parasites with a Hosts file
http://mvps.org/win2002/hosts.htm
links provided as a courtesy, read all instructions on the pages before use

Grateful thanks to the authors and webmasters
_


<bulldog8@lycos.com> wrote in message
news:3a0e0dba-0e30-4d3c-b477-e33f067892ff@a23g2000hsc.googlegroups.com...
> I have a user input form that allows them to provide a description of
> their request. Unfortunately when downloading and processing the data
> their carriage returns \line feeds cause problems.
>
> It is php on a Linux machine. I've tried the following:
>
> $comment = nl2br($comment);
> $comment = str_replace("<br>"," ",$comment);
>
> And this
>
> $order = array("\r\n", "\n", "\r");
> $replace = ' ';
> $comment = str_replace($order, $replace, $comment);
>
> And this
>
> $comment = str_replace("\r"," ",$comment);
> $comment = str_replace("\n"," ",$comment);
>
> but the output in the file always has a '^M' where the linefeed would
> be:
>
> 999~05/25/2008~05/26/2008~3~test 3 after^M
> before~argh!~A
>
>
> Anyone know how to cleanly remove the offending CRLF
>
> Thanks!
> Jon


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h56.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09975 seconds with 10 queries