Tag Archive for rar content in php

How to read the rar content in php?

To read the rar content in php, you should have your rar extension enabled first. The extension is located in /php/ext directory. To enable it add this line to php.ini file.
extension = php_rar.dll

If you don’t have a .dll file then it could be downloaded from here php_rar.dll

function read_rar_file($rarfile) {
$rar_file = rar_open($rarfile) or die("Can't open Rar archive");
$entries = rar_list($rar_file); // each entry of a rar

foreach ($entries as $entry) {
	$stream = $entry->getStream(); 
	$file = '';
	while (!feof($stream)) {
		$buff = fread($stream, 8192);
		if ($buff !== false) {
			$file .= $buff; // file content for a rar file
		}else {
        $each_file_content[$entry->getName()] = $file;