Hello George,

intersting code :-)

You can also avoid that by using
$arr[(string)$book] = 1;
instead of
$arr["$book"] = 1;

marcus

Monday, October 27, 2003, 8:08:28 AM, you wrote:

> 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:
>>
>>> Works fine from CVS. This was most likely fixed with the iterator 
>>> stuff from
>>> Marcus.
>>
>>> Rob
>>
>>> From: George Schlossnagle
>>>> 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";
>>>>    }
>>>> }
>>
>>
>>
>>
>> -- 
>> Best regards,
>>  Marcus                            mailto:[EMAIL PROTECTED]
>>
>> -- 
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> -- George Schlossnagle
> -- Principal Consultant
> -- OmniTI Computer Consulting, Inc.
> -- +1.410.872.4910 x202
> -- 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E  56C2 B2B9 262F 1100 A5A0



-- 
Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to