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
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..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.