为什么80%的码农都做不了架构师?>>>
下面是 PHP 把 text.txt 文本里的json数据读取出来, 然后输出PHP的数组数据
$file_path="text.txt";
$conn = file_get_contents('text.txt');
$conn = prepareJSON($conn);
$conn = str_replace(array("\r\n", " ", "\n"), "", $conn);
print_r(json_decode($conn,true));
function prepareJSON($input){
$input = mb_convert_encoding($input,'UTF-8','ASCII,UTF-8,ISO-8859-1');
if(substr($input,0,3) == pack("CCC",0xEF,0xBB,0xBF)) $input = substr($input,3);
return $input;
}
下面是text.txt 文本 存放了json 数据
{"code":0,"msg":"success","version":"1.0.0","data":{"channel_no":"1003002","channel_name":"城西支行","time":"2016-10-2716:26:07","business":[{"color":"blue","icon":"fa-list-alt","name":"个人业务","schar":"P","sid":"187f0c61f001439787ee55916c30ee79","id":1469255169113,"children":[{"color":"blue","icon":"fa-list-alt","name":"综合业务","schar":"C","sid":"d304bf11bdda4e62a85e186c0539f403","id":1469255169114}]},{"color":"blue","icon":"fa-list-alt","name":"综合业务","schar":"","sid":0,"id":1469255169115,"children":[{"color":"blue","icon":"fa-list-alt","name":"yugy","schar":"","sid":0,"id":1474532427718,"children":[{"color":"blue","icon":"fa-list-alt","name":"综合业务","schar":"C","sid":"d304bf11bdda4e62a85e186c0539f403","id":1474532427718}]}]}],"counters":[{"cno":2,"led":2,"call":2,"enable":false,"regulation":[{"sid":"187f0c61f001439787ee55916c30ee79","weight":13},{"sid":"d304bf11bdda4e62a85e186c0539f403","weight":11}]},{"cno":3,"led":3,"call":3,"enable":true,"regulation":[{"sid":"d304bf11bdda4e62a85e186c0539f403","weight":10},{"sid":"187f0c61f001439787ee55916c30ee79","weight":6}]},{"cno":1,"led":1,"call":1,"enable":true,"regulation":[{"sid":"187f0c61f001439787ee55916c30ee79","weight":13},{"sid":"d304bf11bdda4e62a85e186c0539f403","weight":11}]}],"staffs":[{"no":"10020333","name":"aa"},{"no":"0205815","name":"admin"},{"no":"0205153","name":"admin"},{"no":"10002021","name":"乐棋"}],"template":[{"Text":"标题排队号"}]}}