From an Adwords URL I see this:
http://someaddress.com?utm_expid=123456-8&987654&gclid=Cladskrjelasdjf
What I want to parse out of this with $_GET is the 987654 in the middle. Is this possible since it's not a variable?
UPDATE:
Here's what I found to work:
$keys = array_keys($_GET);
foreach ($keys as $value) {
if (preg_match('/9876/', $value)) {
$acntKey = $value;
}
}
echo "The account key value = " . $acntKey;
The account key value = 987654
The account key value can be any 9876** hence the preg_match. My only concern is if the 9876 shows up on another key - extremely unlikely.
Yes it is possible. You can use array_keys().
$keys = array_keys($_GET);
Then You can loop through $keys
to find the number you want.
If you're going to loop it...
foreach($_GET as $key => $value) {
...
}
Will get you the key/pair value for everything in the $_GET var.
Which will give you:
utm_expid => 123456-8,
987654 => null,
gclid => Cladskrjelasdjf
To give you more an exact answer which sounds like you might be looking for; this will give you that value.
foreach($_GET as $keys=>$value){
if($keys != "utm_expid" && $keys != "gclid"){
echo $keys; // value is 987654
$nVar = $keys; // you can then assign it to a new var too.
}
}
The value will be stored in the new variable.