- var_dump: documentation ( source)
- array_walk_recursive: documentation ( source)
<?php
$a = [
1 => [
[
'key' => 'fe',
'name' => 'En plantilla a dedicación completa',
'dedication' => self::FULLTIME,
'relationship' => self::EMPLOYEE
],
[
'key' => 'ff',
'name' => 'Freelance a dedicación completa',
'dedication' => self::FULLTIME,
'relationship' => self::FREELANCER
],
],
2 => [
[
'name' => 'En Plantilla',
'childs' => [
[
'key' => 'pem',
'name' => 'Mañanas',
'dedication' => self::PARTTIME,
'relationship' => self::EMPLOYEE,
'shiftPreference' => self::MORNING_SHIFT
],
[
'key' => 'pea',
'name' => 'Tardes',
'dedication' => self::PARTTIME,
'relationship' => self::EMPLOYEE,
'shiftPreference' => self::AFTERNOON_SHIFT
],
[
'key' => 'ped',
'name' => 'Indistinto',
'dedication' => self::PARTTIME,
'relationship' => self::EMPLOYEE,
'shiftPreference' => self::DOES_NOT_MATTER
],
],
],
[
'name' => 'Freelance',
'childs' => [
[
'name' => 'Mañanas',
'childs' => [
[
'key' => 'pfmm',
'name' => 'Más de 3 horas/día',
'dedication' => self::PARTTIME,
'relationship' => self::FREELANCER,
'shiftPreference' => self::MORNING_SHIFT,
'hoursOfService' => self::MORE_THAN_3H
],
[
'key' => 'pfml',
'name' => 'Menos de 3 horas/día',
'parent' => 8,
'dedication' => self::PARTTIME,
'relationship' => self::FREELANCER,
'shiftPreference' => self::MORNING_SHIFT,
'hoursOfService' => self::LESS_THAN_3H
],
],
],
[
'name' => 'Tardes',
'childs' => [
[
'key' => 'pfam',
'name' => 'Más de 3 horas/día',
'dedication' => self::PARTTIME,
'relationship' => self::FREELANCER,
'shiftPreference' => self::AFTERNOON_SHIFT,
'hoursOfService' => self::MORE_THAN_3H
],
[
'key' => 'pfal',
'name' => 'Menos de 3 horas/día',
'dedication' => self::PARTTIME,
'relationship' => self::FREELANCER,
'shiftPreference' => self::AFTERNOON_SHIFT,
'hoursOfService' => self::LESS_THAN_3H
],
],
],
[
'name' => 'Indistinto',
'childs' => [
[
'key' => 'pfdm',
'name' => 'Más de 3 horas/día',
'dedication' => self::PARTTIME,
'relationship' => self::FREELANCER,
'shiftPreference' => self::DOES_NOT_MATTER,
'hoursOfService' => self::MORE_THAN_3H
],
[
'key' => 'pfdl',
'name' => 'Menos de 3 horas/día',
'dedication' => self::PARTTIME,
'relationship' => self::FREELANCER,
'shiftPreference' => self::DOES_NOT_MATTER,
'hoursOfService' => self::LESS_THAN_3H
],
],
],
],
],
],
];
$results = $a[1];
array_walk_recursive($results, function(&$a){
unset($a['dedication'], $a['relationship'], $a['shiftPreference'], $a['hoursOfService']);
});
var_dump($results);
var_dump($a);