PHP class to convert files encoding
You can install it with composer:
composer require descom/file_encoding
encodeFile($file, $encoding_to, $encodings_detected);
This is an example:
use Descom\File\Encoding;
$codification = new Encoding();
$file = 'file.txt';
$encoding_to = 'UTF-8';
$encodings_detected = 'UTF-8,ISO-8859-1,WINDOWS-1252';
$result = $codification->encodeFile($file, $encoding_to, $encodings_detected);
http://php.net/manual/es/mbstring.supported-encodings.php
$encoding_to = 'UTF-8';
$encodings_detected = 'UTF-8,ISO-8859-1,WINDOWS-1252';