php 读取world 文档 转字符串 匹配 文字,url 连接

需要先安装com 扩展,若没有 百度下载,注意 需要转换处理下字符

php.ini 添加

extension=php_com_dotnet.dll

com.allow_dcom = true


 //--------------------------------------------------------------------------------------------------------------
header("Content-type:text/html;charset=utf-8");

    $filename = "./test.docx"; 
    $word = new COM("word.application") or die("Can’t start Word!");
    //echo "Loading Word, v. {$word->Version}";

    $word->Documents->open(dirname(__FILE__)."/test.docx"); 

    $str= $word->ActiveDocument->content->Text;

    $str= iconv('GB2312', 'UTF-8', $str);

  preg_match_all('((https?|ftp|gopher|telnet|file|notes|ms-help):'.'((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)',
    $str, $matches, PREG_PATTERN_ORDER);

      echo "-----------------------------------------------------------------------";
      echo "<br/>";
      if($_GET['s']){    
 
            $count=substr_count($str,$_GET['s']);

            echo $_GET['s']." 出现了:".$count."次";
      }

      echo "<br/>";
      echo "-----------------------------------------------------------------------";
      echo "<br/>";
    //var_dump( ($matches));die;

    foreach($matches[0] as $v){

        var_dump($v); echo '<br/>';    

    }
      echo "<br/>";

      echo "-----------------------------------------------------------------------";
die;

 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值