Jump to content

unique ID by array_ shift?


etrader

Recommended Posts

I want to give a unique ID for each run of my php script. I was thinking of creating an array(1,2,3,4,5...), as I can regularly take the first value and delete. Is there any command like array_ shift to do so?

 

array_ shift take the first item but does not permanently delete it; thus, it will be the first item again in the next run.

 

Or do you have a subtle idea for assigning unique ID to each run?

Link to comment
https://forums.phpfreaks.com/topic/236857-unique-id-by-array_-shift/
Share on other sites

well you can you can set a variable to a value...say one...for this example we'll say that $i=1, and at the end of your script you could say $1++ which will increment the number every time the script is run...there are numerous ways to do what you want...you could tweak your idea a, use what i told you , you a database...sessions etc..

That won't work. If you initialize a variable at the beginning of a script and increment it at the end, when the script runs again, the variable is initialized again at the same value as the last time the script ran, not the incremented value. You're going to need to store a value in a database or in a file and increment the value that way.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.