This should be simple to answer, I'm just very new to this all...
If I have the following (the 89 is NOT constant — it could be 2, sometimes 3 numbers — but the /100 is):
89/100
how can I get just 89 saved as an integer?
I Would explode on the /
explode('/','89/100');
then your result would be in the start of the array.
You can just use intval():
$num = intval($string);
This parses the string as an integer, and in this case, ignores everything from the "/" onwards.
To be clear, this will not include the "100".
intval("89/100") => 89
Here's a phpfiddle showing that it works: http://phpfiddle.org/main/code/n1b-reb
You can split the string up by the delimiter /
, with explode()
.
$string = '89/100';
$data = explode('/', $string);
// 89
$number = (int)$data[0];