rewrite to php