//An array is special if every even index contains an even number and every odd index contains an odd number.
var_dump(isSpecialArray([2, 7, 4, 9, 6, 1, 6, 3]));//➞ true
var_dump(isSpecialArray([2, 7, 9, 1, 6, 1, 6, 3]));//➞ false
var_dump(isSpecialArray([2, 7, 8, 8, 6, 1, 6, 3]));//➞ false
function isSpecialArray($array){
foreach($array as $key=>$value){
if($key%2+$value%2==1){
return "Array is not special";
}
}
return "Array is special";
}