I have a unique problem.
I have a few arrays that each have 2 items and are in the following form:
$arr=Array
(
[TEAM1] => 113.03
[TEAM2] => 103.52
)
I am trying to create a function that given the array ($arr) and one of the keys (TEAM1), it would return the other key (TEAM2). The array will always only have 2 values and the key you put in will always exist.
My problem is that I have no idea how to start this.. if the key was 0 or 1 it would be easy selecting the other row but for this I am not sure how to start
$str = 'TEAM2'; $notTeam2 = array_diff_key($arr, [$str => null]);Demo$result = preg_grep("/$key/", array_keys($arr), PREG_GREP_INVERT);unset $arr[$key];reset($arr);$value = current($arr);should do it.