If your data is smaller than the expected count with the list expansion:
<?php
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user, $pass, $uid, $gid, $gecos, $home, $shell,$nu) = explode(":", $data);
?>
The result is a warning not an error:
PHP Warning: Undefined array key 7 in ...
The solution is to pad the array to the expected length:
<?php
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user, $pass, $uid, $gid, $gecos, $home, $shell,$nu) = array_pad( explode(":", $data), 8, "");
// where 8 is the count of the list arguments
?>