[Clients] => Array
(
[Client] => Array
(
[ClientDetails] => Array
(
[clientName] =>
[clientContact] =>
[clientContactEmail] =>
[clientTelephone] =>
)
[properties] => Array
(
<?php
$Clients = Array
(
'Client' => Array
(
'ClientDetails' => Array
(
'clientName' => '',
'clientContact' =>'',
'clientContactEmail' => 'client1@example.com',
'clientTelephone' => '',
),
'properties' => Array
(
'Property' => Array
(
0 => Array
(
'propertyid' => '',
'lastUpdateDate' => '',
'category' => '',
'Address' =>'',
)
)
),
),
'Client2' => Array
(
'ClientDetails' => Array
(
'clientName' => '',
'clientContact' =>'',
'clientContactEmail' => 'client2@example.com',
'clientTelephone' => '',
),
'properties' => Array
(
'Property' => Array
(
0 => Array
(
'propertyid' => '',
'lastUpdateDate' => '',
'category' => '',
'Address' =>'',
)
)
),
)
);
function mySearch($search, $data, $parents = array())
{
$return = [];
if(is_array($data))
{
foreach($data as $key => $value)
{
if($key === $search)
{
$return[] = array (
'key' => array_merge($parents, array($key)),
'value' => $value,
);
}
else if(is_array($value))
{
$return = array_merge($return, mySearch($search, $value, array_merge($parents, array($key))));
}
}
}
return $return;
}
header('content-type: text/html; charset=utf-8;');
echo '<pre>';
@print_r(mySearch('clientContactEmail' , $Clients));
echo '</pre>';
exit(__FILE__ .': '. __LINE__);
$properties = array();
array_walk_recursive($rawData, function($value, $key) use(&$properties) {
if ($key === 'properties') {
$properties = $value;
}
});