Some array-related questions for which I do not readily find answers in my reference text (McGraw-Hill/Osborne):
I want to define an array containing strings. Whenever a user visits the page, I want to echo a random string from the array. When the visitor refreshes (assume same session, I am not yet advanced enough to consider cookies), I want to echo a different randomly selected string, but exclude from consideration any strings previously echoed that session. I know that I can do this by deleting the array item for any strings that I echo. My first question, though, is this: Does deleting the item remove it from the server for just that user, or is it gone permanently, for everyone? I can also mark the string in some way, so that the script can test for the mark and see whether it's been used. Same question: Does the marking remain when someone else accesses the page?
Next question: If it is gone for good (or if the marking remains), then I imagine I can get around this by copying the entire array and then having the user work with just the copied array. But I can find no internal function to do that copying. Is the only way to copy to loop through the strings in the original array, reading and copying the items into that new array, item by item?
Final question: When multiple users access the page simultaneously, does each user see his or her own "pristine" page, unsullied by the hypothetical deletes that I mentioned above?
Thanks, all, for your availability to educate this neophyte.
A.
Allan Marain



Reply With Quote


Bookmarks