Bir php dosyanız var. Ben index.php dosyasında etiketlere dizi öğeleri yazdım:Bir php dosyasından nasıl yeni dosya okuyabilirim?
<?php
include 'arlequin_parser.php';
$arlequin=new arlequin_parser();
$dizi=$arlequin->arlequin_parser();
?>
[Profile]
Title = "<?= $dizi['profiles']['Title'] ?>"
NbSamples = <?= $dizi['profiles']['NbSamples'] ?>
DataType = <?= $dizi['profiles']['DataType'] ?>
GenotypicData = <?= $dizi['profiles']['GenotypicData'] ?>
LocusSeparator = <?= $dizi['profiles']['LocusSeparator'] ?>
MissingData = "<?= $dizi['profiles']['MissingData'] ?>"
GameticPhase = <?= $dizi['profiles']['GameticPhase'] ?>
RecessiveData = <?= $dizi['profiles']['RecessiveData'] ?>
[Data]
<?php foreach ($dizi['Data'] as $key=>$value): ?>
[[Samples]]
SampleName = "<?= $value['SampleName'] ?>"
SampleSize = <?= $value['SampleSize'] ?>
SampleData = {
<?php foreach ($value['SampleData'] as $k=>$v): ?>
<?= $v['individual'] ?> <?= $v['repetition'] ?> <?= $v['data']['dataString1'] ?>
<?= $v['data']['dataString2'] ?>
<?php endforeach; ?>
}
<?php endforeach; ?>
Ve yeni bir dosya tıklayarak oluşturmak yapabilirim file.How index.php okuma dataları ile yeni bir metin dosyası (newtext.txt) istiyorum Bir düğme veya bir href bağlantısı. newtext.txt olmalıdır: kod ama kod aşağıdaki deneyin
[Profile]
Title = "Hello World"
NbSamples = 52
DataType = MICROSAT
GenotypicData = 1
LocusSeparator = WHITESPACE
MissingData = "?"
GameticPhase = 0
RecessiveData = 0
[Data]
[[Samples]]
SampleName = "pop_82"
SampleSize = 24
SampleData = {
696 6969 669
598 6965 658
}
çalışmıyor:
$output = file_get_contents('index.php');
$file = fopen('new_text.txt', 'w');
fwrite($file, $output);
fclose($file);
Nasıl yapabilirim? 'index' php dosya içeriği yerine 'Your Text' yerine –
güncellendi bir örnek ile cevap – Nadir
Bu kodu deneyin ama çalışmıyor: –