Considering that you didn't use var
to declare the variable it is available to every function and all code in the global scope and beyond because without the var
the variable is created in the global scope.
Answering your question though, if you want the variables created inside a function to exist beyond the life of a function, use a closure. You could give the variable to some object accessible outside the function which has the job of storing a bunch of these values.
If you want the variable (created in JavaScript and therefore I assume on the client) to be accessible to your PHP back end you'll have to send a request to your server. Probably an ajax call if this execution isn't part of submitting a form.