Enhanced php function