guarding key() from calling with null eg. $button = key($content['button']) --> key($content['button'] ?? []) or check before !empty($content['button'])