Hi folks I have a php script running on a cron job that produces a xml file from the data in my MySQL database, its all working great but I would like to include the line breaks that appear in the data field Bullet1. The code below works fine but outputs all the text straight after each other.
$xml .= "<Features><![CDATA[".$r["Bullet1"]."]]></Features>";
or
$xml .= "<Location>".$r["NearestTown"]."</Location>";
I am trying to use this type of code to add a <BR> but its not working any help would be appreciated.
$xml .= "<Features><![CDATA[".stripcslashes(ereg_replace("(\r\n|\n|\r)", "<br />".$r["Bullet1"]))."]]></Features>";
or
$xml .= "<Location>".stripcslashes(ereg_replace("(\r\n|\n|\r)", "<br />".$r["Bullet1"]))."</Location>";
Steve
Need to include <BR> in php to xml script.
Moderator: General Moderators
-
scoobysteve
- Forum Newbie
- Posts: 14
- Joined: Wed Jul 30, 2014 5:19 am
Need to include <BR> in php to xml script.
Last edited by scoobysteve on Mon Aug 11, 2014 7:10 am, edited 1 time in total.
Re: Need to include <BR> in php to xml script.
ereg_replace has been deprecated. Sounds like you want a simple nl2br() though.
-
scoobysteve
- Forum Newbie
- Posts: 14
- Joined: Wed Jul 30, 2014 5:19 am
Re: Need to include <BR> in php to xml script.
Thanks again.
I can get that to work in a normal php listing all vaules using
echo nl2br($row['Bullet1']);
But I cant seem to get it to work in the xml export script.
$xml .= "<Location>".nl2br($r['Bullet1'])."</Location>";
this works below but does not includes <BR>
$xml .= "<Location>".$r["Bullet1"]."</Location>";
I can get that to work in a normal php listing all vaules using
echo nl2br($row['Bullet1']);
But I cant seem to get it to work in the xml export script.
$xml .= "<Location>".nl2br($r['Bullet1'])."</Location>";
this works below but does not includes <BR>
$xml .= "<Location>".$r["Bullet1"]."</Location>";