Extract Rar Files - Php

How to extract rar files using php code?

Snippet Code

Rate this page :
  [ 0 votes]

Rar package should be installed before rar file extraction. The extract function extracts rar file and save it to the desired file path. The following php code can be used to unrar files.

<?php $rarfile = rar_open('demo.rar') or die("Can't open Rar archive"); $entries = rar_list($rarfile); foreach ($entries as $entry) { echo 'Filename: ' . $entry->getName() . "n"; $entry->extract('/dir/extract/to/'); } rar_close($rarfile); ?>


Ask Questions

Ask Question