Array
(
[0] => Array
(
[id] => 21593653
[name] => Тестетст
[last_modified] => 1507314529
[account_id] => 13989537
[date_create] => 1507314514
[created_user_id] => 1327239
[modified_user_id] => 1327239
[responsible_user_id] => 1327239
[group_id] => 0
[closest_task] => 0
[linked_company_id] =>
[company_name] =>
[tags] => Array
(
)
[type] => contact
[custom_fields] => Array
(
[0] => Array
(
[id] => 173200
[name] => Телефон
[code] => PHONE
[values] => Array
(
[0] => Array
(
[value] => +71231123123
[enum] => 397482
)
)
)
[1] => Array
(
[id] => 554037
[name] => Источник:
[values] => Array
(
[0] => Array
(
[value] => /
)
)
)
[2] => Array
(
[id] => 173202
[name] => Email
[code] => EMAIL
[values] => Array
(
[0] => Array
(
[value] => tes@test.ru
[enum] => 397494
)
[1] => Array
(
[value] => wazeze@test.ru
[enum] => 397494
)
)
)
)
[linked_leads_id] => Array
(
[0] => 9398317
)
)
)
$array[0]['custom_fields'][2]['values'][0]['value'];
$array[0]['custom_fields'][2]['values'][1]['value'];
function getCustomField($code, $object)
{
$result = [];
foreach ($object['custom_fields'] as $customField) {
if ($customField['code'] !== $code) {
continue;
}
foreach ($customField['values'] as $value) {
$result[] = $value['value'];
}
}
return array_values(array_unique($result));
}
$emails = getCustomField("EMAIL", $object);
$emails = implode("; ", getCustomField("EMAIL", $object));
$email = array_shift(getCustomField("EMAIL", $object));