On 05.01.2018 at 01:11, jans wrote:
> I am having trouble debugging this? I can't get it to print out the value if it is even or the word "odd" if it is odd? The initial funcitons work but I don't know how to use the array_filter with two conditions?
Why do you want to filter the array for this purpose? It seems to me
the simplest approach would be to iterate over the array, and then
conditionally printing what is desired. For instance:
<?php
$arr = array(1,2,6,7,9,4,10,11,12,3,13,24);
foreach ($arr as $val) {
echo ($val%2 ? "odd" : $val), PHP_EOL;
}
--
Christoph M. Becker