A
A
alexzen2018-05-20 11:59:05
PHP
alexzen, 2018-05-20 11:59:05

How to access an element of an object in php?

There is a variable, let's say $a. Here is the output of its value in var_dump:

object(TrackableObject)#67 (4) {
  ["storage":"TrackableObject":private]=>
  array(34) {
    ["direction"]=>
    string(7) "inbound"
    ["callstatus"]=>
    string(7) "ringing"
    ["starttime"]=>
    string(19) "2018-05-20 15:27:07"
    ["endtime"]=>
    string(0) ""
    ["totalduration"]=>
    NULL
    ["billduration"]=>
    string(0) ""
    ["recordingurl"]=>
    string(0) ""
    ["sourceuuid"]=>
    string(47) "in_287e79670fc6de7285a5aadfd9b04e06_105"
    ["gateway"]=>
    string(0) ""
    ["customer"]=>
    string(3) "365"
    ["user"]=>
    string(1) "1"
    ["customernumber"]=>
    string(11) "79130000000"
    ["customertype"]=>
    string(8) "Contacts"
    ["incominglinename"]=>
    string(0) ""
    ["assigned_user_id"]=>
    string(0) ""
    ["createdtime"]=>
    string(19) "2018-05-20 11:27:08"
    ["modifiedtime"]=>
    string(19) "2018-05-20 11:27:08"
    ["source"]=>
    string(0) ""
    ["created_user_id"]=>
    string(0) ""
    ["sp_is_local_cached"]=>
    string(0) ""
    ["sp_recordingurl"]=>
    string(0) ""
    ["sp_is_recorded"]=>
    string(0) ""
    ["sp_recorded_call_id"]=>
    NULL
    ["sp_voip_provider"]=>
    string(7) "provider"
    ["sp_call_status_code"]=>
    NULL
    ["sp_called_from_number"]=>
    string(11) "70000000000"
    ["sp_called_to_number"]=>
    string(11) "70000000000"
    ["starred"]=>
    string(0) ""
    ["tags"]=>
    string(0) ""
    ["sp_is_recorder"]=>
    NULL
    ["sp_billduration"]=>
    NULL
    ["label"]=>
    string(11) "70000000000"
    ["modifiedby"]=>
    string(1) "1"
    ["id"]=>
    int(377)
  }
  ["trackingEnabled":"TrackableObject":private]=>
  bool(true)
  ["tracking":"TrackableObject":private]=>
  bool(true)
  ["changed"]=>
  array(1) {
    [0]=>
    string(2) "id"
  }
}

I don't know what php code to write to get to the ["storage":"TrackableObject":private] object to get the value of the customernumber array element. The $a->storage["customernumber"] construct doesn't work. How to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hnkhame, 2018-05-20
@alexzen

You cannot access a private property, in theory there should be a public method that returns this property, for example like this: sandbox.onlinephpfunctions.com/code/38bd8772d5950f...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question