Comment on page
PHP
get_object_vars($object)
可以把一個 object 變成一個 key-value 格式的 array。array_values($array)
可以把 key-value 格式的 array 的 value 變成一個 array。
json_decode($foo)
會回傳 Object,改成用json_decode($foo, true)
就會回傳 key-value 格式的 array。json_decode()
在 32bit 的機器上,處理夠大的 long 值會出現流失精準度的問題,解法是換成字串(WTF)function json_decode_suck($json) {return json_decode(preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"',$json));}
PDOStatement::execute($array)
的 array 長度,必須與 SQL 指令中用到的 parameter 數量相同,不然會炸 error。
Last modified 3yr ago