2014-11-06 54 views
0

我想在php中閱讀韓文語言,計數字符,來自ppt文件的單詞。我用下面的PHP代碼讀取PPT文件,但它不讀韓國語 -如何在php中讀取ppt文件?

function parsePPT($filename) { 
    // This approach uses detection of the string "chr(0f).Hex_value.chr(0x00).chr(0x00).chr(0x00)" to find text strings, which are then terminated by another NUL chr(0x00). [1] Get text between delimiters [2] 
    $fileHandle = fopen($filename, "r"); 
    $line = fread($fileHandle, filesize($filename)); 
    $lines = explode(chr(0x0f),$line); 
    $outtext = ''; 

    foreach($lines as $thisline) { 
     if (strpos($thisline, chr(0x00).chr(0x00).chr(0x00)) == 1) { 
      $text_line = substr($thisline, 4); 
      $end_pos = strpos($text_line, chr(0x00)); 
      $text_line = substr($text_line, 0, $end_pos); 
      $text_line = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\[email protected]\/\_\(\)]/"," ",$text_line); 
      if (strlen($text_line) > 1) { 
       $outtext.= substr($text_line, 0, $end_pos)."\n"; 
      } 
     } 
    } 

    return $outtext; 
} 

$filename = "test_pptk.ppt"; 
$ppt_string = parsePPT($filename); 

請告訴我關於PHP代碼,可以閱讀PPT文件韓文等多國語言。我也想要統計這樣的ppt文件中的字符數和字數。

+0

請不要發佈重複的問題 - 相反,你應該編輯你的原始問題:http://stackoverflow.com/questions/26775665/how-to-read-korean-language-ppt-file-in-php – GoBusto 2014-11-06 12:42:14

回答

0

嘗試使用PHPPowerPoint庫。

+0

我如何使用phppowerpoint庫。我試圖用它來要求安裝composer.json,請告訴我使用PHPPowerPoint庫的步驟。 Thanx – 2014-11-07 04:21:10

+0

'require_once'path/to/PhpPowerpoint/src/PhpPowerpoint/Autoloader.php'; \ PhpOffice \ PhpPowerpoint \ Autoloader :: register();' – makhov 2014-11-07 04:36:11