bonjour ,

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
function readsunspotdata($aFile, &$aYears, &$aSunspots) {
    $lines = @file($aFile,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
    if( $lines === false ) {
        throw new JpGraphException('Can not read sunspot data file.');
    }
    foreach( $lines as $line => $datarow ) {
        $split = preg_split('/[\s]+/',$datarow);
        $aYears[] = substr(trim($split[0]),0,4);
        $aSunspots[] = trim($split[1]);
    }
}
 
$year = array();
$ydata = array();
readsunspotdata('yearssn.txt',$year,$ydata);
// ------------------------
foreach($datarow as $datarow ){
echo $datarow.'<br>';
}
Fichier yearssn.txt :
1700.5   5.0  
1701.5  11.0  
1702.5  16.0  
1703.5  23.0  
1704.5  36.0  
1705.5  58.0  
1706.5  29.0  
1707.5  20.0  
1708.5  10.0  
1709.5   8.0
Après ajout du foreach , pour tester , il n'y a pas de data disponible .
C'est pour utiliser jpgraph :

Pouvez vous donner quelques conseils ?

@+