Get/Post variables from a string?
Posted: Thu Jun 18, 2009 3:33 pm
Hello everyone,
I'm working on a statistics thing for a website, to track visitors, popular pages, etc. (It has to work offline, otherwise I'd use analytics)
Right now I have all of the URL's and Referrers being dumped into a database. Now it's not really a full "website" its just a little program, and it displays information based on the get variables.
For example, every page is index.php.
Here's a few examples:
http://localhost/kioskdb/index.php?idle=1
http://localhost/kioskdb/index.php?view_category=6
http://localhost/kioskdb/index.php?viewnorm=149&back=4
How do I extract just the "149" or just the "4"?
I've got the first 2 worked out. Doing a split on the ? and looking for the "view_category" tag, but how do I do that on the 3rd line? I'd end up with 149&back=4
I suppose I could do another split on the & sign, but is there a more efficient way? Maybe something in PHP that can read those "get" variables from a string without me having to break it into 10 pieces?
I'm working on a statistics thing for a website, to track visitors, popular pages, etc. (It has to work offline, otherwise I'd use analytics)
Right now I have all of the URL's and Referrers being dumped into a database. Now it's not really a full "website" its just a little program, and it displays information based on the get variables.
For example, every page is index.php.
Here's a few examples:
http://localhost/kioskdb/index.php?idle=1
http://localhost/kioskdb/index.php?view_category=6
http://localhost/kioskdb/index.php?viewnorm=149&back=4
How do I extract just the "149" or just the "4"?
I've got the first 2 worked out. Doing a split on the ? and looking for the "view_category" tag, but how do I do that on the 3rd line? I'd end up with 149&back=4
I suppose I could do another split on the & sign, but is there a more efficient way? Maybe something in PHP that can read those "get" variables from a string without me having to break it into 10 pieces?