no save
Assistance
Achat
News

Forum | webmastering
[php] expressions régulières
kij_82, le mar. 17 mai 2005 à 10:17:14
En effet, il te faur ereg, mais pour cela, il aut que tu lise ligne par ligne ton fichier avec la fonction fgets.
Ensuite tu fais une selection sur le début de ligne qui correspond à la suite suivante de caractère : [tous sauf caractère séparateur]
Et tu prend la valeur premièere du tableau retourné (ereg retourne un tableau).
Voilà un exemple :


<?php
$fd = fopen( "monfichier.txt","r");
while( !feof($fd)) {
$buffer = fgets($fd, 4096);
if( ereg( "([^ ]{1,*}(.*)", $buffer, $regs) ){
echo "Partie selectionnee : ".$regs[0]."<BR>";
}
else
echo "pas de partie selectionnée ou pb<BR>";
}
close($fd);
?>

++



PrécédentDinheru
mai 05
Dinheru
mai 05
Suivant
REPONSES
kij_82
mai 05
Dinheru
mai 05
kij_82
mai 05
teebo
mai 05
kij_82
mai 05
kij_82
mai 05
Dinheru
mai 05
kij_82
mai 05
Dinheru
mai 05
kij_82
mai 05
Version Web
Réalisé par RedShift
no save