Basic array / object property navigation

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Can someone please point me to a good tutorial with PHP examples on
how to navigate the properties within an object/array?

I've never used web services before and have written a simple script
using SOAP (NuSOAP) to look up the definition of a word
(  The response is
straightforward, but changes in structure from query to query.

One query I got, the definition was in
['WordDefinition'].  The next time it returned a response without a
definition, and the key wasn't in the response.  I got that working,
and the next query the first definition was in $response
['WordDefinition'].  I'm just guessing how this works, but I'm sure
there's some logic behind it and somewhere I can learn how to reliably
get at that WordDefinition.  Any advice appreciated.


Re: Basic array / object property navigation

Mike schreef:
Quoted text here. Click to load it

Hi Mike,

Navigating? Well, just dump the stucture.
For arrays:
echo "<pre>";
echo "<pre>";

For Objects you better use var_dump()

As for navigating:
foreach ($response as $key => $value){
   // do you stuff

Erwin Moller

"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare

Site Timeline