htpasswd_read ()

array htpasswd_read ($file = '.htpasswd');
      

This function reads htpasswd file and returns an account array. The keys contain the user names, the values the crypted password. The returned argument can be passed to http_auth directly.

# Authenticate using local .htpasswd file.
include 'lib/http_auth.php';
include 'lib/htpasswd.php';
http_auth (htpasswd_read ('.htpasswd'), 'Admin login');