我已在数据库中将此数组保存为String
:
Array
(
[item_number1] =>1
[payment_date] => 04:21:34 Dec 06, 2014 PST
[payment_status] => Completed
[first_name] => sdfsd
[last_name] => parsdfsdandekar
[quantity1] => 1
)
现在,我想使用所有数组值。
如何获取它们?
答案 0 :(得分:0)
在将数组保存到数据库之前首先使用JSON_ENCODE
,如果要再次获取内容,请使用JSON_DECODE
$arr = array(
"item_number1" => "1",
"payment_date" => "04:21:34 Dec 06, 2014 PST",
"payment_status" => "Completed",
"first_name" => "sdfsd",
"last_name" => "parsdfsdandekar",
"quantity1" => "1"
);
echo json_encode($arr);
JSON_ENCODE
之后的结果(数组到JSON字符串):
{ "item_number1" => "1", "payment_date" => "04:21:34 Dec 06, 2014 PST", "payment_status" => "Completed", "first_name" => "sdfsd", "last_name" => "parsdfsdandekar", "quantity1" => "1" }