Q:

Generate Random ID in PHP with no zeros, o's, ones's, or L's

I would like to create a random ID like an airline ticket with out any zeros, o's, ones's, or L's.  It would be nice if server time was used in the generation process so no two IDs will be the same.  How would one do this?

A:

Following the awesome PHP naming scheme:
function generate_airline_ticket_number($length) {
  $characters = '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ';
  $max = strlen($characters) - 1;
  $string = '';

  for ($i = 0; $i < $length; $i++) {
    $string .= $characters[mt_rand(0, $max)];
  }

  return $string;
}

I should submit this to be included into PHP6 ;)

If you're worried about collisions, my approach would be to do an endless loop:
do
{
  $random_stuff = generate_airline_ticket_number(10);
} while(check_if_string__is_not_in__the_database($random_stuff));

