Re: PHP 5 Beta 2 RC1
| From: | George Schlossnagle | Date: | Mon, 27 Oct 2003 07:08:28 +0000 |
| Subject: | Re: PHP 5 Beta 2 RC1 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-5031@lists.php.net to get a copy of this message | ||
There's also an auto-casting issue. If you have something like:
$xml = simplexml_load_file("a.xml");
print_r($xml);
foreach($xml->book as $book) {
$arr[$book] = 1;
}
<books>
<book>foo</book>
<book>bar</book>
</books>
you get an illegal offset error in the assignment to $arr. It's attempting to use it as a simpleXML object.
If you instead do:
$xml = simplexml_load_file("a.xml");
print_r($xml);
foreach($xml->book as $book) {
$arr["$book"] = 1;
}
It works fine.
On Monday, October 27, 2003, at 01:47 AM, Marcus BXrger wrote:
Hello Robert, George, yes, the simplexml/foreach was borked before and can be considered fixed now. marcus Monday, October 27, 2003, 2:03:24 AM, you wrote:-- Principal Consultant -- OmniTI Computer Consulting, Inc. -- +1.410.872.4910 x202 -- 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0Works fine from CVS. This was most likely fixed with the iterator stuff from Marcus.RobFrom: George Schlossnagle-- Best regards,The following code loops indefinitely. $conf = simplexml_load_file("status.xml"); foreach($conf->services->service as $service) { print $service->params->description."\n"; foreach($service->params as $foo) {print "$foo\n";} }Marcus mailto:helly@php.net-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- George Schlossnagle