PHP best way to MD5 multi-dimensional array?

后端 未结 13 1997
别那么骄傲
别那么骄傲 2020-12-07 11:48

What is the best way to generate an MD5 (or any other hash) of a multi-dimensional array?

I could easily write a loop which would traverse through each level of the

13条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 12:33

    there are several answers telling to use json_code,

    but json_encode don't work fine with iso-8859-1 string, as soon as there is a special char, the string is cropped.

    i would advice to use var_export :

    md5(var_export($array, true))
    

    not as slow as serialize, not as bugged as json_encode

提交回复
热议问题