Page 1 of 1

Bug or am I being dumb

Posted: Wed Jul 06, 2005 10:55 am
by John Cartwright

Code: Select all

function format2xml($xml) {
	$transaction = '<TRANSACTION>';
	foreach ($xml as $keyname => $value) {
		$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
	}
	$transaction .= '</TRANSACTION>';
	return $transaction;
}
Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to gt;';
foreach ($xml as $keyname => $value) {
$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'&gt;';
}
$transaction .= '&lt;/TRANSACTION&gt;';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I hANSACTION>';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '&a;amp;gt; $value) {
		$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
	}
	$transaction .= '</TRANSACTION>';
	return $transaction;
}
Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a lction = '<TRANSACTION>';
foreach ($xml as $keyname => $value) {
$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
}
$transaction .= '</TRANSACTION>';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '&ampfunction format2xml($xml) {
	$transaction = '<TRANSACTION>';
	foreach ($xml as $keyname => $value) {
		$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
	}
	$transaction .= '</TRANSACTION>';
	return $transaction;
}
Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</function format2xml($xml) {
	$transaction = '<TRANSACTION>';
	foreach ($xml as $keyname => $value) {
		$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
	}
	$transaction .= '</TRANSACTION>';
	return $transaction;
}
Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will rech ($xml as $keyname => $value) {
$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
}
$transaction .= '</TRANSACTION>';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I have no idea what's going on and have never encountered this. Any thoughts?

Edit| It returns the middle value 'cart' not 'jay'amp;gt; $value) {
$transaction .= '<'.$keyname.'&gt;'.$value.'&lt;/'.$keyname.'&gt;';
}
$transaction .= '</TRANSACTION>';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrl($xml) {
$transaction = '<TRANSACTION>';
foreach ($xml as $keyname => $value) {
$transaction .= '&lt;'.$keyname.'&gt;'.$value.'</'.$keyname.'>';
}
$transaction .= '</TRANSACTION>';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and]

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I have no idea what's going on and have never encountered this. Any thoughts?

Edit| It returns the middle value 'cart' not 'jay'= '<TRANSACTION>';
foreach ($xml as $keyname =&gt; $value) {
$transaction .= '&lt;'.$keyname.'&gt;'.$value.'&lt;/'.$keyname.'&gt;';
}
$transaction .= '&lt;/TRANSACTION&gt;';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I have no idea what's going on and have never encountered this. Any thoughts?

Edit| It returns the middle value 'cart' not 'jay'nsaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I have no idea what's going on and have never encountered this. Any thoughts?

Edit| It returns the middle value 'cart' not 'jay' $transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
}
$transaction .= '&lt;/TRANSACTION&gt;';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'caTION>';
foreach ($xml as $keyname => $value) {
$transaction .= '&lt;'.$keyname.'&gt;'.$value.'&lt;/'.$keyname.'&gt;';
}
$transaction .= '&lt;/TRANSACTION&gt;';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :function format2xml($xml) {
$transaction = '<TRANSACTION>';
foreach ($xml as $keyname => $value) {
$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
}
$transaction .= '</TRANSACTION>';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I have no idea what's going on and have never encountered this. Any thoughts?

Edit| It returns the middle value 'cart' not 'jay't;TRANSACTION>';
foreach ($xml as $keyname => $value) {
$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'&gt;';
}
$transaction .= '&lt;/TRANSACTION&gt;';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I have no idea what's going on and have never encountered this. Any thoughts?

Edit| It returns the miamp;lt;/'.$keyname.'>';
}
$transaction .= '</TRANSACTION>';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I have no idea what's going on and have never encountered this. Any thoughts?

Edit| It returns the middle value 'cart' not 'jay'function format2xml($xml) {
$transaction = '<TRANSACTION>';
foreach ($xml as $keyname => $value) {
$transaction .= '<'.$keyname.'>'.$value.'</'.$keyname.'>';
}
$transaction .= '</TRANSACTION>';
return $transaction;
}

Okay the array I pass to it is fine, but the < and > are disapeering and only the last $keyname is appearing in the string. Sort of a weird thing to happen. But I wrote a little test echo to see if I was just forgetting something in this function

Code: Select all

echo '<jay>cart</jay>';
and all that will return is 'cart'
Same results as my function... :roll: I have no idea what's going on and have never encountered this. Any thoughts?

Edit| It returns the middle value 'cart' not 'jay'

Posted: Wed Jul 06, 2005 11:00 am
by Chris Corbyn
Huh? That's really weird :?

So if you tried to file_get_contents() a local HTML document and echo() the content (nothing else in that script) it would just display junk?

There's nothing wrong with the PHP code :?

EDIT | Or echo '<b>d11wtq</b>'; isn't bold?

Posted: Wed Jul 06, 2005 11:07 am
by John Cartwright
hrmm it seems taht when I look in the source it is

Code: Select all

<jay>cart</jay>
I guess it is returning the expected values.. my bad :roll: the browser was just trying to parse it... I guess it was me being st00pid.

Add me to the 'Finest moment Award'

Posted: Wed Jul 06, 2005 11:13 am
by Chris Corbyn
Jcart wrote:hrmm it seems taht when I look in the source it is

Code: Select all

<jay>cart</jay>
I guess it is returning the expected values.. my bad :roll: the browser was just trying to parse it... I guess it was me being st00pid.

Add me to the 'Finest moment Award'
Hahaha, I did wonder but didn't wanna ask (hence why I asked to do some valid HTML) :P Glad you worked it out ;)

Posted: Wed Jul 06, 2005 11:42 am
by timvw
Btw, you might want to run http://www.php.net/htmlentities on the values, to make sure the xml remains valid.... or use <![CDATA[ <html> ]]>...