tqla Posted August 31, 2010 Share Posted August 31, 2010 Hello. Can someone show the syntax to echo the variable from the array below that is showing "2010-08-31 23:19"? I need to grab that date and use it elsewhere in my script. Thanks. array(19) { ["name"]=> string( "com_jumi" ["params"]=> array(0) { } ["mainframe"]=> &object(JSite)#2 (6) { ["_clientId"]=> int(0) ["_messageQueue"]=> array(0) { } ["_name"]=> string(4) "site" ["scope"]=> string( "com_jumi" ["_errors"]=> array(0) { } ["requestTime"]=> string(16) "2010-08-31 23:19" } Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 31, 2010 Share Posted August 31, 2010 If I am reading that correctly you would reference it thusly: echo $arrayName['mainframe']['requestTime']; //Output: 2010-08-31 23:19 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted August 31, 2010 Share Posted August 31, 2010 You should be able to access it like any other array element: $array_name['requestTime'] Quote Link to comment Share on other sites More sharing options...
tqla Posted September 1, 2010 Author Share Posted September 1, 2010 Thanks. Quote Link to comment Share on other sites More sharing options...
tqla Posted September 1, 2010 Author Share Posted September 1, 2010 So in this case (below) what is the $arrayName? I've tried com_jumi but it did not work. I know how to get array elements but this has me beat. Array ( [name] => com_jumi [params] => Array ( ) [mainframe] => JSite Object ( [_clientId] => 0 [_messageQueue] => Array ( ) [_name] => site [scope] => com_jumi [_errors] => Array ( ) [requestTime] => 2010-09-01 00:39 ) Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 1, 2010 Share Posted September 1, 2010 It's a property of an object in an array, so: echo $array['mainframe']->requestTime; Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 1, 2010 Share Posted September 1, 2010 So in this case (below) what is the $arrayName? I've tried com_jumi but it did not work. I know how to get array elements but this has me beat. Array ( [name] => com_jumi [params] => Array ( ) [mainframe] => JSite Object ( [_clientId] => 0 [_messageQueue] => Array ( ) [_name] => site [scope] => com_jumi [_errors] => Array ( ) [requestTime] => 2010-09-01 00:39 ) The only way to get the output you posted is by doing var_dump($something); so whatever $something is, is what $array is in my example. Quote Link to comment Share on other sites More sharing options...
tqla Posted September 1, 2010 Author Share Posted September 1, 2010 AbraCadaver, I used: print_r ( get_defined_vars() ); Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 1, 2010 Share Posted September 1, 2010 No, that won't give you that output, but try: echo $mainframe->requestTime; Quote Link to comment Share on other sites More sharing options...
tqla Posted September 1, 2010 Author Share Posted September 1, 2010 BOOM! That works! Thanks AbraCadaver! Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 1, 2010 Share Posted September 1, 2010 BOOM! That works! Thanks AbraCadaver! Cool, just to clarify, the output in your original post is from a var_dump() The follow-ups are print_r(). I quoted one and didn't even look at it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.