Changing Queue Agent

Hi All,
I have an assignment that, I have to change the queue agent phone number to another, once the particular agent left the office based on his punchout time. Is there anyway that we can acheive this. If it is through php, then it will be easy to understand.