关于php:从随机字符中删除“==”的最佳方法

best way to remove “==” from random characters

本问题已经有最佳答案,请猛点这里访问。

为什么base64以==结尾?有时以==结尾,以随机字符结尾。

我想知道如何从随机字符中删除那些==或=。从随机字符中删除这些=的最佳和正确方法是什么?

这是移除这些==的最佳方法吗?

1
str_replace("=","",$url)


从维基百科

An additional pad character is allocated which may be used to force
the encoded output into an integer multiple of 4 characters (or
equivalently when the unencoded binary text is not a multiple of 3
bytes) ; these padding characters must then be discarded when decoding
but still allow the calculation of the effective length of the
unencoded text, when its input binary length would not be a multiple
of 3 bytes (the last non-pad character is normally encoded so that the
last 6-bit block it represents will be zero-padded on its least
significant bits, at most two pad characters may occur at the end of
the encoded stream).