tags:

views:

24

answers:

3

I've got this line of code:

$xml_output .= "\t<Event=" . $x . ">\n";

And it will output:

<Event=0>

<Event=1>

<Event=2>

etc etc through my loop.

I need it to output as this (with the quotes around the number):

<Event="0">

<Event="1">

<Event="2">

Any help, and I'm sure it's simple would be greatly appreciated!

A: 

$xml_output .= "\t<Event=\"" . $x . "\">\n";

However, that is not valid xml.

jishi
yeah, i missed off the event id= bit. Fixed that npw. It's late, a schoolboy error
Simon Hume
A: 
$xml_output .= "\t<Event=\"" . $x . "\">\n";

PHP Strings

To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash before a single quote, or at the end of the string , double it (\\). Note that attempting to escape any other character will print the backslash too.

jasonbar
Perfect, thanks! I don't do much PHP, so a real help. Thank you
Simon Hume
A: 
$xml_output .= "\t<Event=\"" . $x . "\">\n";

The slash escapes the quote for output. More information about double quoted strings can be found in the PHP manual

akamike