I just did this in Tcl, so I'm sure of the exact PHP syntax, but you need to encode the string username:password in base64 and then pass in the encoded string in the http headers. (the colon is literal.)
I guess you need are base64_encode() and header(). again i'm not sure of exact PHP syntax but header call should be something similar to:
header(Authorization: basic:$base64_encoded_string)
(p.s. the Tcl tutorial I used to do this is located at http://www.bluetitan.com/~tdarugar/td/tcl/http_pwd_tcl.html )