php
  • file
  • 2017-12-07 6 views 0 likes 
    0

    私はpdfファイルの検索文字列へのスクリプトを書いています。私はこのリンクからスクリプトを使用した:link。 私のスクリプトは、すべてのファイルをPDFに検索しないので、私はPHP複数のファイルを検索する文字列pdfとこのファイルの名前を取得

    (名前でソートされた)最初のファイルのみで検索し、問題を抱えている私のスクリプト:

    foreach (glob("storage/cvs/*.pdf") as $file) { 
        // $files = 'storage/cvs/d08540965a_2017-12-06.pdf'; 
        $this->pdf2text->setFilename($file); 
        $this->pdf2text->decodePDF(); 
        $convert2Txt = $this->pdf2text->output(); 
    
        if (stripos($convert2Txt, $query) !== false) { 
         echo $resultQuery = "tak ".$file."</br>"; 
        } else { 
         echo $resultQuery = "nie znaleziono ".$file."</br>"; 
        } 
    
    } 
    

    そして私は、私は名前を得ることができる方法がわかりませんファイルが見つかりました。

    答えて

    0

    これは、私はそれを行う方法です。

    $dir = "/path/to/your/directory/"; // Set your directory path here 
    if (is_dir($dir)){    // Check its a directory 
        if ($dh = opendir($dir)){  // Open the directory 
         while (($file = readdir($dh)) !== false){ // Read the files 
          if (substr($file, -3)=='pdf') { // Check filename ends 'pdf' 
           // Your code here 
    

    $fileは、ファイル名

    として設定されます
    関連する問題