Would that work? Yeah... I wouldn't advise storing the cleartext passwords in the PHP file, as that's a bit of a security risk.
At the very least, you should store the passwords as ciphertext; then encrypt the user-entered password using the same algorithm, and match that against the stored ciphertext.
But there's no reason why that code wouldn't work -- assume you're requesting the user's name/password via a login form?