hasan-22/open

它会读取整个文件,并且你可以对其执行一系列操作

v1.0.0 2023-01-24 08:57 UTC

This package is auto-updated.

Last update: 2024-09-29 05:49:15 UTC


README

它会读取整个文件,并且你可以对其执行一系列操作

它非常容易使用

安装

 composer require hasan-22/open

函数

例如,我们想要向我们的文件中添加一些文本


$file = \Open\Open::ready();

$result = $file->open('file.txt')
->append('word','word1')
->appendTo('word2',1)
->prepend('word3','word4')
->prependTo('word5',2)
->clean()
->write();

or 

We want to add text to our file and then receive a array output

$result = $file->open('file.txt')
->append('word','word1')
->appendTo('word2',1)
->prepend('word3','word4')
->prependTo('word5',2)
->clean()
->write()->readLines();

print_r($result);

Sample output
[
    [0] => word3
    [1] => word4
    [2] => word5
    [3] => word
    [4] => word1
    [5] => word2
]

!!!! 如果你只想获取输出而不写入文件,请省略write()方法。 !!!!

例如

$result = $file->open('file.txt')
->append('word','word1')
->appendTo('word2',1)
->readLines();

print_r($result);

Sample output
[
    [0] => word
    [1] => word1
    [2] => word2
]