$data=DB::table('novel_sections')->where('novel_id',188699)->take(2)->get();
        $data=json_decode($data,true);
        foreach ($data as $k=>$v)
        {
            $lines['title'] = $v['title'];
            $lines['content'] = file_get_contents($v['content']);
            $content_02 = htmlspecialchars_decode($lines['content']);//把一些预定义的 HTML 实体转换为字符
$content_03 = str_replace(" ","",$content_02);//将空格替换成空
            $lines['content'] = strip_tags($content_03);//函数剥去字符串中的 HTML、XML 以及 PHP 的标签,获取纯文本内容
//$con = mb_substr($contents, 0, 100,"utf-8");//返回字符串中的前100字符串长度的字符
            $arr[]=$lines;
        }

        file_put_contents("C:/3.txt",serialize($arr));

        file_put_contents("C:/3.txt",json_encode($arr));

        $datas = json_decode(file_get_contents("C:/3.txt"));

        print_r($datas);

<?php
$url = "http://www.jb51.net";
$contents = file_get_contents($url);
//如果出现中文乱码使用下面代码
//$getcontent = iconv("gb2312", "utf-8",$contents);
echo $contents;
?>

标签: none

添加新评论