<?php
function odd($var)
{
// retourne lorsque l'entrée est impaire
return($var & 1);
}
function even($var)
{
// retourne lorsque l'entrée est paire
return(!($var & 1));
}
$array1 = array( 0 => 'a',
1 => 2,
2 => 4,
3 => 'd');
echo "Impair :\n";
print_r(array_filter($array1, "odd"));
//echo "Pair :\n";
//print_r(array_filter($array2, "even"));
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Impair :
Fatal error: Uncaught TypeError: Unsupported operand types: string & int in /in/Bb2fK:6
Stack trace:
#0 [internal function]: odd('a')
#1 /in/Bb2fK(21): array_filter(Array, 'odd')
#2 {main}
thrown in /in/Bb2fK on line 6
Process exited with code 255. - Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
- Impair :
Warning: A non-numeric value encountered in /in/Bb2fK on line 6
Warning: A non-numeric value encountered in /in/Bb2fK on line 6
Array
(
)
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.1 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20
- Impair :
Array
(
)
- Output for 5.1.0
- Fatal error: fatal flex scanner internal error--end of buffer missed in /in/Bb2fK on line 23
Process exited with code 255.
preferences:
236.52 ms | 401 KiB | 359 Q