I use PHP 8.2(CodeIgniter 3).PHP Error was encountered. It worked fine PHP 7.4
Error message
Message: Implicit conversion from float 20.5 to int loses precision Filename: libraries/Hashids.php Line Number: 220
$half_length = (int)(strlen($alphabet) / 2);
while (strlen($ret) < $this->_min_hash_length) {
$alphabet = $this->_consistent_shuffle($alphabet, $alphabet);
$ret = substr($alphabet, $half_length) . $ret . substr($alphabet, 0, $half_length);
$excess = strlen($ret) - $this->_min_hash_length;
if ($excess > 0)
$ret = substr($ret, $excess / 2, $this->_min_hash_length); // Line Number 220
}
The code showing the error is below
$ret = substr($ret, $excess / 2, $this->_min_hash_length);
I found similar question as below.But I couldn't get it to work properly. Implicit conversion from float (number) to int loses precision
I tried modifying the code in my own way, but since I don't have any knowledge of PHP, I think it would be less confusing if I didn't write it, so I would like to refrain from writing it.
I am using Google Translate because I am not native English speaker.