What's new

PHP Pahelp naman po about sa PHP

SakuraX

Honorary Poster
Joined
Oct 30, 2018
Posts
145
Reaction
25
Points
128
Ask ko lang po kung paano maggenerate ng serial number sa php or kahit random number and letters?
 
Try niyo po magtanong sa stackoverflow....maraming sasagot doon na expert...linawin mo lang yung tanong mo....dapat din po english
 
get mo yung current time then gamit ka md5 function
Tama siya, para walang identical. Medyo challenging to if ever naka database kasi you need to check whether the generated serial number is already existing but varies on the format you like.
ex:
Code:
<?php
//gerate auto SSN based on current date and record number
//ex: 20210301/0002
 $datesn=date("Ymd");

 $rec_no=1; //record count, increment 1 if exxisting from the list
 //str_pad for padded string or with leading zeros with size of n
 //visit: https://www.php.net/manual/en/function.str-pad.php
    echo $datesn.'/'.str_pad($rec_no,4,0,STR_PAD_LEFT);
?>
 
uniqid() - The uniqid() function generates a unique ID based on the microtime (the current time in microseconds).

PHP:
<?php
echo uniqid();
?>

Ref: You do not have permission to view the full content of this post. Log in or register now.

use MD5 or SHA1: md5(), sha1()
PHP:
<?php
echo(md5('string here'));
echo(sha1('string here'));
?>

Ref: You do not have permission to view the full content of this post. Log in or register now. , You do not have permission to view the full content of this post. Log in or register now.

use substr and str_shuffle

PHP:
<?php
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz';
echo substr(str_shuffle($permitted_chars), 0, 10);
?>

Ref: You do not have permission to view the full content of this post. Log in or register now.
at madami pang iba.
 
Last edited:

Similar threads

Back
Top