(.*?)<\/inflection>#ie", $content, $matches); foreach ($matches[1] as $key => $value) { $matches[1][$key] = trim($value); } return implode("#", $matches[1]); } $names = file("Names/girl_full.txt"); $r = fopen("Names/girl_full_result.txt", "w"); foreach ($names as $key => $value) { $nn = get_text($value); fwrite($r, $nn . "\n"); } fclose($r); ?>