Password Validation in php

<?php
if (!preg_match('~^[a-z0-9]*[0-9][a-z0-9]*$~i',$password)) {
         // $subject is alphanumeric and contains at least 1 number
         $passworderror="Please enter password with digits";
 }
?>