Hello friends i am reading a folder in which i have many text files in PHP and i need to remove all the spaces from the starting of each paragraph in text file. But when i am reading file and tried to remove space its not working like i tried **TRIM** function **LTRIM** and also tried REGEX **"/\s+$/"** but all are not working. But when i am using REGEX this **"/\s+/"** instead of **"/\s+$/"** its removing all the spaces. I need only remove space from the beginning of paragraph any help please...Below is my code that i am trying..

```
if ($dh = opendir($folder_path)){
    while (($file = readdir($dh)) !== false) {
        $path_parts = pathinfo($file);
        if ($path_parts['extension'] === 'txt' && $file1 = fopen($folder_path . '/' . $file, "r")) {
            $cleanStr ="";
            while(!feof($file1)) {
                $line = trim(fgets($file1));
                if ( trim($line)!="" ){
                    $str = preg_replace("/\s+$/", " ", ltrim($line));
                    echo $str;die;
                }
            }
        }
    }
    echo "Process finished..." . PHP_EOL;
    closedir($dh);
}

```