@ 2014-04-10T15:55:53Z <?php
function getValues(&$egElement, $property, $option = NULL) {
if(is_array($egElement) === FALSE) {
return array();
}
if(is_int($option) and $option > 1) {
$values = array();
foreach($egElement as $key => $egSubElement) {
$values = array_merge(
$values,
getValues($egSubElement, $property, $option - 1)
);
}
return $values;
}
if(
is_string($option) or
$option === TRUE
) {
$values = array();
foreach($egElement as $key => $eElement) {
if(array_key_exists($property, $eElement)) {
if(is_string($option)) {
$values[$key] = call_user_func_array($option, array($eElement[$property]));
} else if($option === TRUE) {
$values[$key] = &$egElement[$key][$property];
}
}
}
reset($egElement);
} else {
return array_column($egElement, $property);
}
return $values;
}
getValues(array(
1 => array('id' => 4, 'dragon' => array('toto' => 5, 'titi' => 6)),
2 => array('id' => 5, 'dragon' => array('toto' => 5, 'titi' => 6)),
3 => array('id' => 6, 'dragon' => array('toto' => 5, 'titi' => 6)),
4 => array('id' => 7, 'dragon' => array('toto' => 5, 'titi' => 6)),
5 => array('id' => 8, 'dragon' => array('toto' => 5, 'titi' => 6)),
6 => array('id' => 9, 'dragon' => array('toto' => 5, 'titi' => 6)),
7 => array('id' => 10, 'dragon' => array('toto' => 5, 'titi' => 6)),
8 => array('id' => 11, 'dragon' => array('toto' => 5, 'titi' => 6)),
));
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.3.0 - 8.3.6 Fatal error: Uncaught Error: getValues(): Argument #1 ($egElement) could not be passed by reference in /in/BpsbB:55
Stack trace:
#0 {main}
thrown in /in/BpsbB on line 55
Process exited with code 255 . Output for 8.1.23 - 8.1.28 , 8.2.10 - 8.2.18 Fatal error: Uncaught Error: getValues(): Argument #1 ($egElement) cannot be passed by reference in /in/BpsbB:55
Stack trace:
#0 {main}
thrown in /in/BpsbB on line 55
Process exited with code 255 . Output for 4.3.2 - 4.3.11 , 4.4.0 - 4.4.9 , 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.28 , 5.4.0 - 5.4.27 Fatal error: Only variables can be passed by reference in /in/BpsbB on line 63
Process exited with code 255 . Output for 4.3.0 - 4.3.1 Fatal error: Only variables can be passed by reference in /in/BpsbB on line 63
preferences:dark mode live preview
123.06 ms | 401 KiB | 137 Q