时间:2021-07-01 10:21:17 帮助过:5人阅读
$string = <<
110171675 张三 2013-08-19 00:02:00 46 24 74750 0 2013-08-19 00:02:00 AM
110171676 我是大美人 2013-08-19 01:15:00 46 24 74501 0 2013-08-19 01:15:00 AM
110171677 李四 2013-08-19 02:09:00 46 24 64519 71411 2013-08-19 02:09:00 AMXML;$xml = simplexml_load_string($string);foreach($xml->P as $item){ $item=(array)$item; $arr[]=array('PN'=>$item['PN'],'PT'=>$item['PT']);}echo json_encode($arr);
$xml =<<< XML[{"PN":"\u5f20\u4e09","PT":"2013-08-19 00:02:00"},{"PN":"\u6211\u662f\u5927\u7f8e\u4eba","PT":"2013-08-19 01:15:00"},{"PN":"\u674e\u56db","PT":"2013-08-19 02:09:00"}]XML;$sm = simplexml_load_string($xml);foreach($sm->P as $item) { $r[] = array('PN' => strval($item->PN), 'PT' => strval($item->PT));}echo json_encode($r);
110171675 张三 2013-08-19 00:02:00 46 24 74750 0 2013-08-19 00:02:00 AM
110171676 我是大美人 2013-08-19 01:15:00 46 24 74501 0 2013-08-19 01:15:00 AM
110171677 李四 2013-08-19 02:09:00 46 24 64519 71411 2013-08-19 02:09:00 AM