$content = file_get_contents($filename);
$content = file_get_contents('test');
$content = str_replace(' ', '', $content);
echo $content;
echo mb_strlen($content);//500;
function post($text){
$post = array(
'type'=>'tns',
'spd'=>5,
'vol'=>5,
'per'=>3
);
$post['tex'] = $text;
$str = http_build_query($post);
$curl = curl_init ( "http://ai.baidu.com/aidemo" );
curl_setopt ( $curl, CURLOPT_HEADER, 0 );
$header = array ();
$header [] = 'Host:www.xfyun.cn';
$header [] = 'Connection: keep-alive';
$header [] = 'User-Agent: ozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1';
$header [] = 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8';
$header [] = 'Accept-Language: zh-CN,zh;q=0.8';
$header [] = 'Cache-Control:max-age=0';
$header [] = 'Content-Type:application/x-www-form-urlencoded';
$cookie = 'BAIDUID=084BFD73232EA1A547CA65AAA04685C1:FG=1; PSTM=1501125759; BIDUPSID=C0BEB044EC7D23B3EF463F77205E6CE0; __cfduid=dc3938de9ef417e3bf51b595c689911731507798871; MCITY=-158%3A; PSINO=7; H_PS_PSSID=1468_24558_21100_17001_22526_24879_20928; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BDSFRCVID=NG_sJeCCxG3uVG7A0fPWa9aG8q4f9TOb_rbj3J; H_BDCLCKID_SF=tR3KB6rtKRTffjrnhPF3Xx-mKP6-3MJO3b7t-q050CJtVM3petQnebo3bGrnW-jd-DrBohFLK-oj-D_wj5K23J; seccode=a2bf83b668786ddfe619b4fab90f01d9; Hm_lvt_fdad4351b2e90e0f489d7fbfc47c8acf=1510041101; Hm_lpvt_fdad4351b2e90e0f489d7fbfc47c8acf=1510041108; FP_UID=fa04bf1fda86235c9d0b5a5e46e592ad; BDUSS=83c3pTZVNzc2x0Ni1OSUh3aHNDdlBIM0RDdFNuRmxEeWxRNHVxYzZXd2o4eWhhSUFBQUFBJCQAAAAAAAAAAAEAAACAd-MwQUNKUFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACNmAVojZgFaZ2';
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt ( $curl, CURLOPT_HTTPHEADER, $header );
curl_setopt ( $curl, CURLOPT_POST, 1);
curl_setopt ( $curl, CURLOPT_POSTFIELDS, $str );
$result = curl_exec ($curl);
curl_close ($curl);
return $result;
}
//根据内容进行转换::
function save_file($data,$filename){
$data = '{"errno":0,"msg":"success","data":"data:audio/x-mpeg;base64,//MoxAAMCG3sAVgYAM8868rhuH4IQkGUoCWj/J30ciHJZhXlb/uXD8/qksLB8oCBQMSBcEFh+mIHfLn+CCrVJQOhKkB9jNZk//MoxAoOkQ68AZhoAIgVNYufuxAiaCX/JROFGLhZ6l0jdAwP/NKebDgJAwNP/zSGP6GFCX/cycZ/8oBA2urFamYC3Y0WfqGD//MoxAoPYNrQAc8YADRHy3n6LYN8m4DcEbLVDHJmc4kP1OMyw9eGfDnxmOUTgsSPuh5xSyuqlpVfpG/07pK6SqqkkqTXbba4//MoxAcPAHcSXkjESgEfDxIRgx5Aw4BFXBiBZ1biWBUiwOB0RhcTXAd6UMOqKnTwiPSM2n+t4aWdBk7T/lstgsmS10ckkkgg//MoxAYOsVbpvntElgB/jXgtQEyg1Oa61VeLcNm6pIh0IC+pSPSNi6J4eus1RSQbzHI/lT8zf/QoIKckMJnP//+m/9U0w3Uw//MoxAYNqJqsANPKTOdOa8IkTGod5Nwf48bWtSFcCkvo/S4k57rwn//xfMfqIZRChh1s4Xh9cUcH06ijv00FB+f+CuCjF6rs//MoxAoPEdbAynhElOMvYCisKv5r///////SqMv5fpCMgM4hlDjkIhFA3NdHQoc5OHzikEyChc4LiCbR3aP6Vepp//29G7oj//MoxAgLqea4AAgKmCLZI6yEYQRkMAw4awYESioYJC6tqRI0jjFFVWETrDqh6HoXt/r82htgNrJdgPLXXr/13BTFdMpTx0LV//MoxBQLsXs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6oAMPYcIsG1OkYXnSBi39YYB/Mi4tUz5cc/WB/xkA0ewXRdfGarCVBYzzlRVk+u2v9pmdpkrugYegASqVGoNhE//MoxF0NQPr+WDDSch4KBwpgSO3xhgmH6VaqEzDLp4uc/0fx0qyOSSSSBSTOERVqPM8z6FYxhfqSLCjlUY6SsNR9UGf7FBXE//MoxGMQOSqtkFDYcQRDzgomC9hf//vQNQ2yIVIsS0o76eAgFF99mi63t/rzjpmzisfMiuju9wNr+32/WFFNwTwWfOn43Rl0//MoxF0M+QrSWUUoA+3oxdiDp1gQKXbCxTjmb47HuJm0N9Pi8NezvWswfqF/ms33Fm3X//6Vjv7//w5Bz//8ojkXCGbKpvrc//MoxGQW6caAAYx4AJP/0daz/Q76vM9V62+9c/Sem3rPdlnGHHUfV9ueYhM6uioxx5hZm2uY32YwweSpcgZ3dyI8gHQUlCJD//MoxEMWSw6wAYZQAXq+lT/nmKknnxEHkb6ITnmi484WQEVV+GsOMK94rgBwYsVtAD41nsKa/hx/741/29////fX/vRqiiMc//MoxCQSkbK0Ac8oALch7s9U0RqiamHCwMPnJ1XSoAloVBIGgddUJTr/6gaFSp3EQdWGlfJp/AFYWJFkynfp9UM06GpAN40P//MoxBQP0a64KntElJqpFExei2/q/////moidiEATkUd2MKVENladaMGKFQUD8911Hr3////+2SVx+BtDmWxeOup6nDEpGYG//MoxA8NwZqwAGhQlLP/////P/f/1/AuZA0o8sEA6aEOVFP3qrqZrtxzmuAJ7/////+93SrLgEjph9L9v5l////////9rxcT//MoxBMMwaaYADhQlJIgALA6HoqHI5rirmHWsqlulmt7WpFaCv/o////7j2SATEAHJEBUgBA35eT///zX////KUpSkARNHy8//MoxBsL6Z59fihElKJq2hlZykcK6ClcAud/U+j/+r//QgYmGSk40UJAyCYxkas1h/2SkZGaiqjs///2ONRVS5pw1EYKhUUC//MoxCYM8Tm4ADDOcDjQmxr///////+tv6haTEFNRTMuOTkuNaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//MoxC0AAANIAAAAAKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//MoxGgAAANIAAAAAKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//MoxKMAAANIAAAAAKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}';
$arr = json_decode($data,true);
$base64_content = $arr['data'];
$che = explode(';base64,',$base64_content);
$typearr = explode('/',$che[0]);
$type = $typearr[count($typearr)-1];
$content = base64_decode($che[1]);
$new_file = time().".{$type}";
if ( file_put_contents($new_file, $content ) ){
echo '新文件保存成功:', $type;
}else{
echo '新文件保存失败';
}
}