/    Sign up×
Community /Pin to ProfileBookmark

Accessing Values of an Array

I am not great at PHP but can write basic code… Normally, i am able to do things at my own but i am stuck in a problem now.

I have this array and i need to access it’s values… the function is not directly available and i am emailing myself the information.

so, if i do [B]var_export($visitor, true)[/B] [I]$visitor[/I] being the array… i get the following output in the email… I am trying to access the values inbetween and have no idea how to do it.

Any tips?

Thank to anyone for helping in advance.

[code=php]PiwikTrackerVisitor::__set_state(array(
‘visitorKnown’ => true,
‘request’ =>
PiwikTrackerRequest::__set_state(array(
‘params’ =>
array (
‘action_name’ => ”,
‘idsite’ => ‘1’,
‘rec’ => ‘1’,
‘r’ => ‘489206’,
‘h’ => ’12’,
‘m’ => ’25’,
‘s’ => ’54’,
‘url’ => ”,
‘urlref’ => ”,
‘_id’ => ‘8a877ccc74f01a3c’,
‘_idts’ => ‘1414531240’,
‘_idvc’ => ‘2’,
‘_idn’ => ‘0’,
‘_refts’ => ‘0’,
‘_viewts’ => ‘1414538938’,
‘cs’ => ‘windows-1252’,
‘pdf’ => ‘1’,
‘qt’ => ‘0’,
‘realp’ => ‘0’,
‘wma’ => ‘1’,
‘dir’ => ‘0’,
‘fla’ => ‘1’,
‘java’ => ‘1’,
‘gears’ => ‘0’,
‘ag’ => ‘0’,
‘cookie’ => ‘1’,
‘res’ => ‘1920×1080’,
‘gt_ms’ => ‘382’,
),
‘isAuthenticated’ => false,
‘tokenAuth’ => NULL,
‘timestamp’ => 1414599957,
)),
‘visitorInfo’ =>
array (
‘location_ip’ => ‘111’,
‘idvisitor’ => ’11’,
‘visit_last_action_time’ => 1414599957,
‘visit_first_action_time’ => 1414599923,
‘idvisit’ => ‘2’,
‘user_id’ => NULL,
‘visit_exit_idaction_url’ => 1,
‘visit_exit_idaction_name’ => ‘0’,
‘visitor_returning’ => ‘1’,
‘visitor_days_since_first’ => ‘1’,
‘visitor_days_since_order’ => ‘0’,
‘visitor_count_visits’ => ‘2’,
‘visit_goal_buyer’ => ‘0’,
‘location_country’ => ‘us’,
‘location_region’ => NULL,
‘location_city’ => NULL,
‘location_latitude’ => NULL,
‘location_longitude’ => NULL,
‘referer_name’ => ”,
‘referer_keyword’ => ”,
‘referer_type’ => ‘1’,
‘location_browser_lang’ => ‘en-us,en’,
‘visit_total_events’ => ‘0’,
‘visit_total_time’ => 35,
‘visit_total_actions’ => ‘visit_total_actions + 1’,
‘visit_total_searches’ => ‘0’,
‘time_spent_ref_action’ => 34,
),
‘configId’ => ”,
‘customVariables’ =>
array (
),
))[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 29.2014 — I'd recommend doing the following after you define it to see what the actual structure is:
[code=php]
echo '<pre>'.print_r($visitor, 1).'</pre>';
[/code]
Copy linkTweet thisAlerts:
@joomlahelpdeskauthorOct 29.2014 — Hi -

thanks for your reply... doing a print_r gets me the following.... i think it's the same.

Would this make things easier for me to access the values.


[code=php]PiwikTrackerVisitor Object
(
[visitorKnown:PiwikTrackerVisitor:private] => 1
[request:PiwikTrackerVisitor:private] => PiwikTrackerRequest Object
(
[params:protected] => Array
(
[action_name] =>
[idsite] => 1
[rec] => 1
[r] => 977404
[h] => 14
[m] => 2
[s] => 59
[url] =>
[_id] => 8a877ccc74f01a3c
[_idts] => 1414531240
[_idvc] => 3
[_idn] => 0
[_refts] => 0
[_viewts] => 1414601694
[cs] => windows-1252
[pdf] => 1
[qt] => 0
[realp] => 0
[wma] => 1
[dir] => 0
[fla] => 1
[java] => 1
[gears] => 0
[ag] => 0
[cookie] => 1
[res] => 1920x1080
[gt_ms] => 319
)

[isAuthenticated:protected] =>
[tokenAuth:protected] =>
[timestamp] => 1414605782
)

[visitorInfo:PiwikTrackerVisitor:private] => Array
(
[location_ip] =>
[idvisitor] =>
[visit_last_action_time] => 1414605782
[visit_first_action_time] => 1414599923
[idvisit] => 2
[user_id] =>
[visit_exit_idaction_url] => 1
[visit_exit_idaction_name] => 0
[visitor_returning] => 1
[visitor_days_since_first] => 1
[visitor_days_since_order] => 0
[visitor_count_visits] => 2
[visit_goal_buyer] => 0
[location_country] => us
[location_region] =>
[location_city] =>
[location_latitude] =>
[location_longitude] =>
[referer_name] =>
[referer_keyword] =>
[referer_type] => 1
[location_browser_lang] => en-us,en
[visit_total_events] => 0
[visit_total_time] => 5860
[visit_total_actions] => visit_total_actions + 1
[visit_total_searches] => 0
[time_spent_ref_action] => 62
)

[configId:PiwikTrackerVisitor:private] => ×·À(Á‚y
[customVariables] => Array
(
)

)[/code]
Copy linkTweet thisAlerts:
@NogDogOct 29.2014 — Sorry, at my quick glance I thought I was looking at the code used to create the array, not a var_dump of it.

As it looks like everything is private/protected, you'll need to see if the relevant class definition has any "getter" methods that make the data you want available, and then look at what they actually return.
Copy linkTweet thisAlerts:
@joomlahelpdeskauthorOct 29.2014 — Not a problem. that's for your reply... I am looking to see if there is something that can be be done these.

The problem is that the the problem i am working on saves all the info in db in encrypted lang... i.e. BLOB or stuff like that... so, i can't just do a directory query... but appreciate the response.

Thanks.
×

Success!

Help @joomlahelpdesk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...