我想用德国货币显示我的输出,我得到了这样的输出,例如Fu009\,但是我需要像这样的"fü“。
<?php
$json = (object) array(
"salutation" = > ''.$order - > order_custom_fields['_billing_anrede'][0].
'',
"title" = > ''.$order - > order_custom_fields['_billing_titel'][0].
'',
"first_name" = > ''.$order - > order_custom_fields['_billing_first_name'][0].
'',
"last_name" = > ''.$order - > order_custom_fields['_billing_last_name'][0].
'',
"street" = > ''.$order - > order_custom_fields['_billing_address_1'][0].
'',
"street_number" = > ''.$order - > order_custom_fields['_billing_address_2'][0].
'',
"address_supplement" = > ''.$order - > order_custom_fields['_billing_company'][0].
'',
"zipcode" = > ''.$order - > order_custom_fields['_billing_postcode'][0].
'',
"city" = > ''.$order - > order_custom_fields['_billing_city'][0].
'',
"country" = > ''.$pais.
'',
"terms_accepted" = > true,
"receiving_mails_accepted" = > ''.$email.
'',
"email" = > ''.$order - > order_custom_fields['_billing_email'][0].
'',
"lottery_accepted" = > false,
"lottery_solution" = > "LOTTERY",
"original_created_at" = > ''.date('Y-m-d\TH:i:sP', strtotime($order - > order_date)).
'',
);
foreach($items as $item) {
$sku = $wpdb - > get_var($wpdb - > prepare('SELECT meta_value FROM dsr_postmeta WHERE meta_key="_sku" AND post_id='.$item['product_id'].
''));
$sku_s = explode('-', $sku);
$camp = $sku_s[0];
$itm_n = $sku_s[1];
$json - > items[] = (object) array(
"campaign_number" = > (int) $camp,
"item_number" = > (int) $itm_n,
);
}
array_push($json_full, $json);
echo json_encode($json_full);
?>我在想help实体,或者utf8,谢谢你的帮助!!
发布于 2014-02-04 11:05:44
如果您使用的是PHP 5.4+,请将echo json_encode($json_full);更改为echo json_encode($json_full, JSON_UNESCAPED_UNICODE);
json_encode预定义常量的完整列表可以在那里找到:http://lt1.php.net/manual/en/json.constants.php
游行示威
代码:
<?php
$json = (object) array(
"uml" => "fü",
);
echo json_encode($json, JSON_UNESCAPED_UNICODE) . PHP_EOL;
echo json_encode($json) . PHP_EOL;输出:
{"uml":"fü"}
{"uml":"f\u00fc"}发布于 2014-02-04 11:30:12
你的字符集设置正确吗?
<head><meta charset="utf-8"></head>https://stackoverflow.com/questions/21550633
复制相似问题