src/Utility/File.php
public static function writeLines($path, $lines)
    {
        if (is_file($path) && !is_writable($path)) {
            throw new RuntimeException("File '$path' is not a writable file");
        }

        // make sure every line has only one newline at the end
        $lines = array_map(function ($line) {
            return rtrim($line);
        }, $lines);

        $bytes = file_put_contents($path, implode("\n", $lines));
        if ($bytes === false) {
            throw new RuntimeException("Something went wrong while writing content to '$path'");
        }

        return true;
    }
public static function writeLines($path, $lines)
    {
        if (is_file($path) && !is_writable($path)) {
            throw new RuntimeException("File '$path' is not a writable file");
        }

        // make sure every line has only one newline at the end
        $lines = array_map(function ($line) {
            return rtrim($line);
        }, $lines);

        $bytes = file_put_contents($path, implode("\n", $lines));
        if ($bytes === false) {
            throw new RuntimeException("Something went wrong while writing content to '$path'");
        }

        return true;
    }
public static function writeLines ( $ path , $ lines ) { if ( is_file ( $ path ) && ! is_writable ( $ path ) ) { throw new RuntimeException ( "File '$path' is not a writable file" ) ; } // make sure every line has only one newline at the end $ lines = array_map ( function ( $ line ) { return rtrim ( $ line ) ; } , $ lines ) ; $ bytes = file_put_contents ( $ path , implode ( "\n" , $ lines ) ) ; if ( $ bytes === false ) { throw new RuntimeException ( "Something went wrong while writing content to '$path'" ) ; } return true ; }
Write array of lines into file

@param string $path Path to file
@param array $lines Content array

@return bool true on success
Write array of lines into file