up vote 0 down vote favorite
share [fb]

I am going through a php script which has something like this

echo "<pre>";
var_export($someObj->details);
echo "</pre>";

and the output is something like : http://pastebin.com/gEAFg6R4

now how do I fetch paricular lines for eg if I just want to fetch the height, if have vehicle or not and is male or female ? what is var_export($someObj->details); doing ?

link|improve this question

define "fetch". – Col. Shrapnel Aug 29 at 4:42
ok let me put it straight. I am working with tera wurfl database. it has a sample php script which after inputing user agent gives output with following pastebin.com/hxJLEiEF . now i just want to fetch few informations from there. like mobile model. either it uses javascript or not etc. the output is from var_export($wurflObj->capabilities); I hope this much info makes my question fair enough. – Candy Gupta Aug 29 at 4:58
feedback

1 Answer

up vote 0 down vote accepted

Please study the PHP manual on arrays http://php.net/manual/en/language.types.array.php - the third example shows how to access nested array contents.

In your case it would be:

print $someObj->details["city"];

print $someObj->details["details"]["have_vehicle"];

Can't tell for the rest, as your output paste is incomplete.

link|improve this answer
thanks for the manual link. btw i have commented new link with full output. and now going through the manual. hope i will be able to figure out :D – Candy Gupta Aug 29 at 5:17
thank you very much for the manual and the answer too :) I now can myself figure out how to fetch :) \m/ \m/ – Candy Gupta Aug 29 at 5:34
Okay cool. Also test out print_r in place of var_dump - I find that it's sometimes more readable for finding the right array tree. – mario Aug 29 at 5:35
sure I will try that. :) – Candy Gupta Aug 29 at 7:32
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.