- var_dump: documentation ( source)
- array_column: documentation ( source)
- array_merge: documentation ( source)
<?php
$testArray = array(
'percy' => array(
'philip' => array(
'mitch' => array(
'percy' => 'hatcherson',
'mitch' => 'anderson'
)
),
'mitch' => array(
'mitchell',
'anderson',
'percy' => array(
'percy',
'hatcherson'
),
'mitchell' => 'thomas mitchell anderson',
'percy' => 'percy philip hatcherson'
)
)
);
$newArray = array();
foreach ($testArray as $k => $v) {
if (is_array($v)) {
$newArray = array_merge($newArray, array_column($v, 'percy'));
}
}
var_dump($newArray);