Re: unable to use vars in foreach

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 	
On Sunday, November 14, 2004, at 08:36PM, Jonathan Villa <jvilla@xxxxxxx> wrote:

>>
>> On Sunday, November 14, 2004, at 08:24PM, Jonathan Villa <jvilla@xxxxxxx>
>> wrote:
>>>
>>>$modules = simplexml_load_file(MODULES);
>>>
>>
>> Are you certain that MODULES has been defined()? And what do you get when
>> you print_r($modules)?
>>
>> -ryan
>>
>
>Yes MODULES is defined.  It's defined in an include file.  In my loop,
>when I echo the $mod->postName the values print just fine.  My issue is in
>the conditional.

AHA!

Here's what I think's going on (sorry I don't have time to investigate it myself)....

$mod->postName is a simplexml object.  Due to some php5 magic, when used it a situation that calls for a string (like echo $xmlobj), it echos the proper value. However, when using it as an array subscript does not appear to qualify as this situation. To solve this try either:

$post[(string)$xmlobj]
OR
$post[strval($xmlobj)]

I hope this is clear and helpful.

-ryan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux