You can use array functions for this.

Set an array with all the digits:

$digits = array("0","1","2","3","4","5","6","7","8","9");

Now split the number to an array:

$str = "914027"; $numDigits = str_split($str);

Now you can use array_diff to find the difference between them:

$missing = array_diff($digits, $numDigits);

The result will be an array with the missin digits:

["3","5","6","8"]

If you have a lot of numbers, put them all in an array, and loop through it.