切断最后两根琴弦后,取下琴弦的其余部分

i have a variable value which may contain

     309  
    1208
   31802

Now, i need to get 3/12/318. mean the rest part of the string after cutting last two string.how can i do it in php.

Do it like that:

substr($string, $start, $length)

substr($string, -3, (strlen($string)-2) * -1);

With this expression, you start at the third from last char of the string and select all the remaining chars to the beginning.

PHP-Documentation for substr: http://php.net/manual/de/function.substr.php

Another way is dividing by 100

<?php
echo (int)(309/100)."
";
echo (int)(1208/100)."
";
echo (int)(31802/100)."
";
?>

https://eval.in/628062