0
我有這樣的元素的關聯數組(的print_r的一部分($元件))讀出時:使用json_encodePHP壞控制字文字,從分貝
[przeplywy] => Array
(
[0] => Array
(
[probes] => Array
(
[0] => sonda-10
)
[flow] => Array
(
[0] => Array
(
[0] => created
[1] => sip
[2] => sport
[3] => dip
[4] => dport
[5] => proto
[6] => sensor
[7] => os
)
[1] => Array
(
[0] => 2013-09-12 06:10:26
[1] => 192.168.0.1
[2] => 18560
[3] => 10.0.0.1
[4] => 1900
[5] => UDP
[6] => sonda-10
[7] =>
)
[2] => Array
(
[0] => 2013-09-12 09:31:08
[1] => 192.168.0.1
[2] => 13011
[3] => 10.0.0.1
[4] => 1900
[5] => UDP
[6] => sonda-10
[7] =>
)
[3] => Array
(
[0] => 2013-09-12 09:37:42
[1] => 192.168.0.1
[2] => 4813
[3] => 10.0.0.1
[4] => 1900
[5] => UDP
[6] => sonda-10
[7] =>
)
[4] => Array
(
[0] => 2013-09-12 11:24:41
[1] => 192.168.0.1
[2] => 50091
[3] => 10.0.0.1
[4] => 1900
[5] => UDP
[6] => sonda-10
[7] =>
)
[5] => Array
(
[0] => 2013-09-12 13:36:55
[1] => 192.168.0.1
[2] => 17064
[3] => 10.0.0.1
[4] => 1900
[5] => UDP
[6] => sonda-10
[7] =>
)
)
)
)
蔭($噸['przeplywy 「]);把它作爲長文本utf8_general_ci保存到MySQL DB中。 在DB我可以把它看作:
[{"probes":["sonda-10"],"flow":[["created","sip","sport","dip","dport","proto","sensor","os"],["2013-09-12 06:10:26","192.168.0.1","18560","10.0.0.1","1900","UDP","sonda-10",""],["2013-09-12 09:31:08","192.168.0.1","13011","10.0.0.1","1900","UDP","sonda-10",""],["2013-09-12 09:37:42","192.168.0.1","4813","10.0.0.1","1900","UDP","sonda-10",""],["2013-09-12 11:24:41","192.168.0.1","50091","10.0.0.1","1900","UDP","sonda-10",""],["2013-09-12 13:36:55","192.168.0.1","17064","10.0.0.1","1900","UDP","sonda-10",""]]}]
當我嘗試解碼它,我得到空和http://json.parser.online.fr/聲稱是因爲 「在字符串字面量不好控制字符」有什麼不好?從查詢結果
似乎不可思議我要使用'json_encode'發送PHP和MySQL之間的數據 - 你爲什麼不使用'mysqli_real_escape_string() '或者什麼的? –
只是複製json'ed字符串phpfiddle並解碼罰款,並返回一個StdClass對象,沒有錯誤 – gwillie
「你爲什麼不使用...」我必須寫一個插件到得很厲害定製,可以將舊MantisBT實例「T升級......(不要問我爲什麼)我不得不使用MantisBT DB接口... – mentis