<?php
 
$input = explode(";", "paierspd;meyal;sbnzare;dbetonen;uroascnciens;geosdasni;miwnge;eadgm;ermtuss;fhisma");
 
for ($i = 0; $i < count($input); $i++) {
    $input[$i] = sorting($input[$i]);
}
 
$result = array();
 
$list = explode("\n", str_replace("\r", "", file_get_contents("list.txt")));
foreach ($list as $entry) {
    $r = sorting($entry);
    for ($i = 0; $i < count($input); $i++) {
        if ($r == $input[$i]) {
            $input[$i] = $entry;
            break;
        }
    }
}
 
echo implode(";", $input);
 
function sorting($w) {
    $w = str_split($w);
    sort($w);
    return implode("", $w);
}
 
?>