Reputation: 644
I have this line of code...
$ide=str_replace('idEdu=', '', $_SERVER['QUERY_STRING']);
In which i get a string which is always a number and I want this string to make it integer.
I want to get for example the number 3 for the url which can be like this one addCV.php?idEdu=3
Can you help me please to achieve that? Thank you
Upvotes: 3
Views: 142
Reputation: 19841
You can either cast as int or use intval():
$num=(int)$_GET['idEdu'];
or
$num=intval($_GET['idEdu']);
Casting should be 4 times as fast.
Upvotes: 2
Reputation: 1691
Have you tried?
$ide = intval(str_replace('idEdu=', '', $_SERVER['QUERY_STRING']));
Upvotes: 0