IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Pointeur fichier


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 25
    Par défaut Pointeur fichier
    Bonjour,
    J'ai des fichiers .txt que j'ouvre pour lire les 10 première lignes du fichier :

    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
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    Full Tilt Poker Game #15547615464: Satellite to the Daily Dollar (114004366), Table 1 - 20/40 - No Limit Hold'em - 9:44:29 ET - 2009/10/24
    Seat 1: welderbird (1,485)
    Seat 2: Rcon1 (1,295)
    Seat 3: Fz3ro (2,210)
    Seat 4: Doggy01870 (1,415)
    Seat 5: jacek3282 (1,290)
    Seat 6: g1nac (1,900)
    Seat 7: exel2007 (935)
    Seat 8: AnilM (1,500)
    Seat 9: mikstas (1,470)
    exel2007 posts the small blind of 20
    AnilM posts the big blind of 40
    The button is in seat #6
    *** HOLE CARDS ***
    Dealt to Fz3ro [Ah Jh]
    mikstas folds
    welderbird folds
    Rcon1 folds
    Fz3ro raises to 120
    Doggy01870 folds
    jacek3282 calls 120
    g1nac folds
    exel2007 folds
    AnilM has 15 seconds left to act
    AnilM folds
    *** FLOP *** [8s 4c 8c]
    Fz3ro checks
    jacek3282 bets 120
    Fz3ro calls 120
    *** TURN *** [8s 4c 8c] [Ks]
    Fz3ro checks
    jacek3282 bets 240
    Fz3ro raises to 1,970, and is all in
    jacek3282 calls 810, and is all in
    Fz3ro shows [Ah Jh]
    jacek3282 shows [Kd Js]
    Uncalled bet of 920 returned to Fz3ro
    *** RIVER *** [8s 4c 8c Ks] [Th]
    Fz3ro shows a pair of Eights
    jacek3282 shows two pair, Kings and Eights
    jacek3282 wins the pot (2,640) with two pair, Kings and Eights
    *** SUMMARY ***
    Total pot 2,640 | Rake 0
    Board: [8s 4c 8c Ks Th]
    Seat 1: welderbird didn't bet (folded)
    Seat 2: Rcon1 didn't bet (folded)
    Seat 3: Fz3ro showed [Ah Jh] and lost with a pair of Eights
    Seat 4: Doggy01870 didn't bet (folded)
    Seat 5: jacek3282 showed [Kd Js] and won (2,640) with two pair, Kings and Eights
    Seat 6: g1nac (button) didn't bet (folded)
    Seat 7: exel2007 (small blind) folded before the Flop
    Seat 8: AnilM (big blind) folded before the Flop
    Seat 9: mikstas didn't bet (folded)
    
    
    
    Full Tilt Poker Game #15547626670: Satellite to the Daily Dollar (114004366), Table 1 - 25/50 - No Limit Hold'em - 9:45:21 ET - 2009/10/24
    Seat 1: welderbird (1,485)
    Seat 2: Rcon1 (1,295)
    Seat 3: Fz3ro (920)
    Seat 4: Doggy01870 (1,415)
    Seat 5: jacek3282 (2,640)
    Seat 6: g1nac (1,900)
    Seat 7: exel2007 (915)
    Seat 8: AnilM (1,460)
    Seat 9: mikstas (1,470)
    AnilM posts the small blind of 25
    mikstas posts the big blind of 50
    The button is in seat #7
    *** HOLE CARDS ***
    Dealt to Fz3ro [4h 4s]
    welderbird calls 50
    Rcon1 folds
    Fz3ro raises to 920, and is all in
    Doggy01870 folds
    jacek3282 folds
    g1nac folds
    exel2007 calls 915, and is all in
    AnilM folds
    mikstas folds
    welderbird folds
    Fz3ro shows [4h 4s]
    exel2007 shows [Ah Ad]
    Uncalled bet of 5 returned to Fz3ro
    *** FLOP *** [2d 6c Jh]
    *** TURN *** [2d 6c Jh] [9c]
    *** RIVER *** [2d 6c Jh 9c] [7h]
    Fz3ro shows a pair of Fours
    exel2007 shows a pair of Aces
    exel2007 wins the pot (1,955) with a pair of Aces
    *** SUMMARY ***
    Total pot 1,955 | Rake 0
    Board: [2d 6c Jh 9c 7h]
    Seat 1: welderbird folded before the Flop
    Seat 2: Rcon1 didn't bet (folded)
    Seat 3: Fz3ro showed [4h 4s] and lost with a pair of Fours
    Seat 4: Doggy01870 didn't bet (folded)
    Seat 5: jacek3282 didn't bet (folded)
    Seat 6: g1nac didn't bet (folded)
    Seat 7: exel2007 (button) showed [Ah Ad] and won (1,955) with a pair of Aces
    Seat 8: AnilM (small blind) folded before the Flop
    Seat 9: mikstas (big blind) folded before the Flop
    
    
    
    Full Tilt Poker Game #15547634042: Satellite to the Daily Dollar (114004366), Table 1 - 25/50 - No Limit Hold'em - 9:45:55 ET - 2009/10/24
    Seat 1: welderbird (1,435)
    Seat 2: Rcon1 (1,295)
    Seat 3: Fz3ro (5)
    Seat 4: Doggy01870 (1,415)
    Seat 5: jacek3282 (2,640)
    Seat 6: g1nac (1,900)
    Seat 7: exel2007 (1,955)
    Seat 8: AnilM (1,435)
    Seat 9: mikstas (1,420)
    mikstas posts the small blind of 25
    welderbird posts the big blind of 50
    The button is in seat #8
    *** HOLE CARDS ***
    Dealt to Fz3ro [5d 4d]
    Rcon1 folds
    Fz3ro calls 5, and is all in
    Doggy01870 has 15 seconds left to act
    Doggy01870 raises to 300
    jacek3282 folds
    g1nac folds
    exel2007 calls 300
    AnilM folds
    mikstas folds
    welderbird folds
    *** FLOP *** [9c 9d 3h]
    Doggy01870 has 15 seconds left to act
    Doggy01870 bets 350
    exel2007 calls 350
    *** TURN *** [9c 9d 3h] [7h]
    Doggy01870 bets 765, and is all in
    AnilM has been disconnected
    exel2007 folds
    Doggy01870 shows [Qh Qd]
    Fz3ro shows [5d 4d]
    AnilM has reconnected
    Uncalled bet of 765 returned to Doggy01870
    *** RIVER *** [9c 9d 3h 7h] [2d]
    Doggy01870 wins the side pot (1,355)
    Doggy01870 shows two pair, Queens and Nines
    Fz3ro shows a pair of Nines
    Doggy01870 wins the main pot (25) with two pair, Queens and Nines
    *** SUMMARY ***
    Total pot 1,380 Main pot 25. Side pot 1,355. | Rake 0
    Board: [9c 9d 3h 7h 2d]
    Seat 1: welderbird (big blind) folded before the Flop
    Seat 2: Rcon1 didn't bet (folded)
    Seat 3: Fz3ro showed [5d 4d] and lost with a pair of Nines
    Seat 4: Doggy01870 showed [Qh Qd] and won (1,380) with two pair, Queens and Nines
    Seat 5: jacek3282 didn't bet (folded)
    Seat 6: g1nac didn't bet (folded)
    Seat 7: exel2007 folded on the Turn
    Seat 8: AnilM (button) didn't bet (folded)
    Seat 9: mikstas (small blind) folded before the Flop
    je désire récupere les 10 premières ligne mais dans la dernières main jouer :

    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
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    Full Tilt Poker Game #15547615464: Satellite to the Daily Dollar (114004366), Table 1 - 20/40 - No Limit Hold'em - 9:44:29 ET - 2009/10/24
    Seat 1: welderbird (1,485)
    Seat 2: Rcon1 (1,295)
    Seat 3: Fz3ro (2,210)
    Seat 4: Doggy01870 (1,415)
    Seat 5: jacek3282 (1,290)
    Seat 6: g1nac (1,900)
    Seat 7: exel2007 (935)
    Seat 8: AnilM (1,500)
    Seat 9: mikstas (1,470)
    exel2007 posts the small blind of 20
    AnilM posts the big blind of 40
    The button is in seat #6
    *** HOLE CARDS ***
    Dealt to Fz3ro [Ah Jh]
    mikstas folds
    welderbird folds
    Rcon1 folds
    Fz3ro raises to 120
    Doggy01870 folds
    jacek3282 calls 120
    g1nac folds
    exel2007 folds
    AnilM has 15 seconds left to act
    AnilM folds
    *** FLOP *** [8s 4c 8c]
    Fz3ro checks
    jacek3282 bets 120
    Fz3ro calls 120
    *** TURN *** [8s 4c 8c] [Ks]
    Fz3ro checks
    jacek3282 bets 240
    Fz3ro raises to 1,970, and is all in
    jacek3282 calls 810, and is all in
    Fz3ro shows [Ah Jh]
    jacek3282 shows [Kd Js]
    Uncalled bet of 920 returned to Fz3ro
    *** RIVER *** [8s 4c 8c Ks] [Th]
    Fz3ro shows a pair of Eights
    jacek3282 shows two pair, Kings and Eights
    jacek3282 wins the pot (2,640) with two pair, Kings and Eights
    *** SUMMARY ***
    Total pot 2,640 | Rake 0
    Board: [8s 4c 8c Ks Th]
    Seat 1: welderbird didn't bet (folded)
    Seat 2: Rcon1 didn't bet (folded)
    Seat 3: Fz3ro showed [Ah Jh] and lost with a pair of Eights
    Seat 4: Doggy01870 didn't bet (folded)
    Seat 5: jacek3282 showed [Kd Js] and won (2,640) with two pair, Kings and Eights
    Seat 6: g1nac (button) didn't bet (folded)
    Seat 7: exel2007 (small blind) folded before the Flop
    Seat 8: AnilM (big blind) folded before the Flop
    Seat 9: mikstas didn't bet (folded)
     
     
     
    Full Tilt Poker Game #15547626670: Satellite to the Daily Dollar (114004366), Table 1 - 25/50 - No Limit Hold'em - 9:45:21 ET - 2009/10/24
    Seat 1: welderbird (1,485)
    Seat 2: Rcon1 (1,295)
    Seat 3: Fz3ro (920)
    Seat 4: Doggy01870 (1,415)
    Seat 5: jacek3282 (2,640)
    Seat 6: g1nac (1,900)
    Seat 7: exel2007 (915)
    Seat 8: AnilM (1,460)
    Seat 9: mikstas (1,470)
    AnilM posts the small blind of 25
    mikstas posts the big blind of 50
    The button is in seat #7
    *** HOLE CARDS ***
    Dealt to Fz3ro [4h 4s]
    welderbird calls 50
    Rcon1 folds
    Fz3ro raises to 920, and is all in
    Doggy01870 folds
    jacek3282 folds
    g1nac folds
    exel2007 calls 915, and is all in
    AnilM folds
    mikstas folds
    welderbird folds
    Fz3ro shows [4h 4s]
    exel2007 shows [Ah Ad]
    Uncalled bet of 5 returned to Fz3ro
    *** FLOP *** [2d 6c Jh]
    *** TURN *** [2d 6c Jh] [9c]
    *** RIVER *** [2d 6c Jh 9c] [7h]
    Fz3ro shows a pair of Fours
    exel2007 shows a pair of Aces
    exel2007 wins the pot (1,955) with a pair of Aces
    *** SUMMARY ***
    Total pot 1,955 | Rake 0
    Board: [2d 6c Jh 9c 7h]
    Seat 1: welderbird folded before the Flop
    Seat 2: Rcon1 didn't bet (folded)
    Seat 3: Fz3ro showed [4h 4s] and lost with a pair of Fours
    Seat 4: Doggy01870 didn't bet (folded)
    Seat 5: jacek3282 didn't bet (folded)
    Seat 6: g1nac didn't bet (folded)
    Seat 7: exel2007 (button) showed [Ah Ad] and won (1,955) with a pair of Aces
    Seat 8: AnilM (small blind) folded before the Flop
    Seat 9: mikstas (big blind) folded before the Flop
     
     
     
    Full Tilt Poker Game #15547634042: Satellite to the Daily Dollar (114004366), Table 1 - 25/50 - No Limit Hold'em - 9:45:55 ET - 2009/10/24
    Seat 1: welderbird (1,435)
    Seat 2: Rcon1 (1,295)
    Seat 3: Fz3ro (5)
    Seat 4: Doggy01870 (1,415)
    Seat 5: jacek3282 (2,640)
    Seat 6: g1nac (1,900)
    Seat 7: exel2007 (1,955)
    Seat 8: AnilM (1,435)
    Seat 9: mikstas (1,420)
    mikstas posts the small blind of 25
    welderbird posts the big blind of 50
    The button is in seat #8
    *** HOLE CARDS ***
    Dealt to Fz3ro [5d 4d]
    Rcon1 folds
    Fz3ro calls 5, and is all in
    Doggy01870 has 15 seconds left to act
    Doggy01870 raises to 300
    jacek3282 folds
    g1nac folds
    exel2007 calls 300
    AnilM folds
    mikstas folds
    welderbird folds
    *** FLOP *** [9c 9d 3h]
    Doggy01870 has 15 seconds left to act
    Doggy01870 bets 350
    exel2007 calls 350
    *** TURN *** [9c 9d 3h] [7h]
    Doggy01870 bets 765, and is all in
    AnilM has been disconnected
    exel2007 folds
    Doggy01870 shows [Qh Qd]
    Fz3ro shows [5d 4d]
    AnilM has reconnected
    Uncalled bet of 765 returned to Doggy01870
    *** RIVER *** [9c 9d 3h 7h] [2d]
    Doggy01870 wins the side pot (1,355)
    Doggy01870 shows two pair, Queens and Nines
    Fz3ro shows a pair of Nines
    Doggy01870 wins the main pot (25) with two pair, Queens and Nines
    *** SUMMARY ***
    Total pot 1,380 Main pot 25. Side pot 1,355. | Rake 0
    Board: [9c 9d 3h 7h 2d]
    Seat 1: welderbird (big blind) folded before the Flop
    Seat 2: Rcon1 didn't bet (folded)
    Seat 3: Fz3ro showed [5d 4d] and lost with a pair of Nines
    Seat 4: Doggy01870 showed [Qh Qd] and won (1,380) with two pair, Queens and Nines
    Seat 5: jacek3282 didn't bet (folded)
    Seat 6: g1nac didn't bet (folded)
    Seat 7: exel2007 folded on the Turn
    Seat 8: AnilM (button) didn't bet (folded)
    Seat 9: mikstas (small blind) folded before the Flop
    je ne vois pas comment procéder...

  2. #2
    Membre Expert Avatar de Bebel
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2003
    Messages
    786
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Avril 2003
    Messages : 786
    Par défaut
    Bonjour,

    a priori tu es obligé de récupérer plus que les 10 dernieres lignes
    Tu dois récupérer des lignes et pour chaque vérifier si elle corresponds ou non à une mise.

    Et quand tu as 10 lignes valides, tu peux arrêter ta lecture. Tu auras ainsi tes 10 dernières mises.

  3. #3
    Membre émérite
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    625
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 625
    Par défaut
    Une manière simple de faire la chose :

    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
     
    $f = file( 'pok_data.txt' ); // on transforme le fichier en tableau
     
     /* on recherche toutes les occurrences de "Full Tilt Poker Game" qui identifie toutes les nouvelles sections
    preg_grep renvoie un tableau indexé array( positionDansTableauOriginal , ligneMatchantPattern )
    */
    $ar = preg_grep('`Full Tilt Poker Game`' , $f );
     
    end( $ar ); // on positionne le pointeur du tableau de résultats sur la dernière occurrence trouvée
     
    $derniereSection = key( $ar ); // on récupère la clé du dernier résultat
     
    $monTab = array_slice( $f , $derniereSection , 10 ); // on récupère 10 lignes dans le tableau original depuis la clé derniereSection
     
    print_r( $monTab );

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 25
    Par défaut merci
    le code ne fonctionne pas, je récupère les 10 premiers ligne du début de fichier et pas de fin :S

  5. #5
    Membre émérite
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    625
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 625
    Par défaut
    Etrange. Ce code fonctionne parfaitement chez moi avec le fichier d'exemple que tu nous as donné.

Discussions similaires

  1. [Tableaux] pointeur de fichier PHP : compteur site
    Par Badaboumpanpan dans le forum Langage
    Réponses: 2
    Dernier message: 29/05/2006, 15h52
  2. Réponses: 1
    Dernier message: 27/11/2005, 14h30
  3. Réponses: 5
    Dernier message: 21/11/2005, 01h40
  4. [swig] python->C->python, pointeur de fichier
    Par PyBio dans le forum Interfaçage autre langage
    Réponses: 1
    Dernier message: 10/11/2005, 15h50
  5. [LG]fichier typé; record et pointeurs
    Par rigel dans le forum Langage
    Réponses: 6
    Dernier message: 12/05/2004, 16h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo