I’ve created some code that automatically posts one message a day on a facebook page of mine.
Those messages contain line breaks.
In my original text in the db the linebreaks are <br />,
but my php code replaces the tag with a \n.
$quote = preg_replace('/(<br \/>)/',' \n',$quote);
Now, the line breaks work fine, except that at the end of each line the \n shows up, too!
So on the facebook page feed it looks like this:
A good traveler leaves no tracks, \n
and a skillful speaker is well rehearsed. \n
Is my replace wrong? Or does anyone have a similar experience?
Thanks.
Special characters like line breaks have to be in double quotes (see php strings documentation):
Also see this example.