Kevin.a Kevin.a - 2 days ago 5
PHP Question

Print array key value

I have an array which i get like this:

$tet = $SimplicateApi->makeApiCall('GET','/crm/person?q[first_name]=Kevin1');


I wanted to see all the array keys inside the array so i did

print_r(array_keys($tet['data']['0']));


The Results:

Array (
[0] => id
[1] => interests
[2] => simplicate_url
[3] => avatar
[4] => linked_as_contact_to_organization
[5] => gender
[6] => first_name
[7] => family_name
[8] => full_name
[9] => email
[10] => phone
)


My question is how do i check whats inside in for example
first_name

Answer

array_keys($array) returns an array of $array keys.


Since the result of array_keys($tet['data']['0']) contains first_name, we can access the value with the [] operator as follows:

print_r($tet['data']['0']['first_name']);

In this code we access $tet['data']['0'] array by 'first_name' key.

Comments