//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";
}
by ვაჟა ტყემალაძე
2 years ago
PHP
Problem Solving
php
Note
Problem
0
Pro tip: use ```triple backticks around text``` to write in code fences