I have this string:
$String = "profile.php?userId=55";
I want to get the number 55, this code just not do it:
$getID = explode("=",$String,2);
Oops, I didn't read your question too well. My answer makes no sense, sorry.
It's in $getID;, not $getID;. In PHP array's are 0-based, i.e., the first part is in $getID; and the second part is in $getID;.
In cases like this it's always a good idea to do a var_dump($getID); to see what's going on.
Also... i wouldnt do it this way unless you -know- that the URL will only ever contain one variable.
For example; if someone sent this as your string:
Then your script will tell you that the value of userId is "55&moo=cow"
For this purpose I'd suggest using some more elegant solutions:
Thank you Lemon,
That's exactly what I'm looking for. Very appreciated.