'fish', 'b' => 'sausage', '&c' => 'whal=asdasd!@£123e'); /** * Return the last element of an array AND it's associated key * @param array (e.g. [ 23, 4, 5, 'fish' => 'beans' ] etc.) * * @return array last element of the array (as [$key => $value]) */ function last_element($array) { $string = http_build_query($array); preg_match('/(&?([^&=]*)=([^&=]*))$/', $string, $matches); $key = urldecode($matches[2]); $value = urldecode($matches[3]); return array($key => $value); } var_dump(last_element($list));