Guest User

Untitled

a guest
Jun 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?PHP
  2.  
  3. $rand = 1000;
  4. for($i=1;$i<=$count[0]['count'];$i++)
  5. {
  6. do
  7. {
  8. // generate id
  9. $record['cart_order_id'] = date("ymd-His-").$rand;
  10. }
  11. // check 1. id is not in db 2. id is not already generated
  12. while ( array_search($record,$existing_id) !== FALSE ||
  13. array_search($record['cart_order_id'],$used) !== FALSE );
  14. // store id
  15. $used[] = $record['cart_order_id'];
  16. // increment counter
  17. $rand = ($rand < 9999) ? $rand+1 : '1000';
  18. }
  19. // output results
  20. echo "id\r\n".implode("\r\n",$used);
  21.  
  22. ?>
Add Comment
Please, Sign In to add comment