integer - pack format "Q" on PHP 5.5 / 32 bit machines


I would like to implement something as described here: in PHP. So far the following seems to be working:


return rtrim(strtr(base64_encode(pack('Q', $int64)), '+/', '-_'), '=');


$bytes = base64_decode(strtr($data, '-_', '+/'));
return unpack('Q', $bytes)[1];

Unfortunately this only works on 64bit systems and PHP5.6.3+ where the "Q" format of pack/unpack was introduced.

What possibilities do I have to implement the same function that would work the same on php5.5 64 & 32 bit?




As pointed out by @Narf, using this: and replacingbase_convert with either: or solved the issue for me.

People are also looking for solutions to the problem: javascript - i want to display my input and the textbox will be remove at the same time in php


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.