Suppose in a file there is a pattern as
sumthing.c: and
asdfg.c: and many more.. with *.c: pattern
Metin yourinput ile değiştirin ve php kullanarak dosyayı kaydetmek nasıl
Kalıptır *.c
teşekkürler ..
Bir PHP string file_get_contents, *.c için yapmanız kullanarak yourinput içine dosyanın içeriğini okuyabilir dize değiştirme ve kullanarak dosyaya geri yazmak file_put_contents:
$filename = '...'; // name of your input file.
$file = file_get_contents($filename) or die();
$replacement = '...'; // the yourinput thing you mention in the quesion
$file = preg_replace('/\b\w+\.c:/',$replacement,$file);
file_put_contents($file,$filename) or die();
İlk açık dosya almak ve onun içeriği:
$content = file_get_contents($path_to_file);
Içeriğini değiştirmek daha:
$content = preg_replace('/.*\.c/', 'yourinput');
Nihayet geri dosyaya kaydedebilirsiniz.
file_put_contents($path_to_file, $content);
Note: Bu yolu daha önce '.c' dize ve her şeyi karşılayan çünkü regexpi değiştirmeyi düşünebilirsiniz. Belki '/[a-zA-Z]*\.c/' istediğiniz şeydir.