SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Expert needed! Trying to cycle through array and replace with predefined regex rules

    PHP ARRAY/REGEX PRO NEEDED!! HEEEEELP!

    In short, I'm trying to re-create a Poker Stars hand history convertor I made a while back. I used to use ereg_replace on a multi-line variable of text, but there were little annoying problems that kept popping up. I decided to split the multi-line variable into an array so that each line was now its own variable, and I figure this will make the searching and replacing much more accurate.

    This is eventually all going to be database driven, but for this example I've turned it into an array. If I can get help on this, I'll have no problem converting it over to the database version.

    I'm basically trying to take a list of predefined REGEX rules (and their replacements), and then if these rules much the individual lines in the newly created array, replace them (so every rule should be checked against every line, and replaced if it matches).

    I must be missing something here, possibly due to the fact that I've been sleep deprived for quite some time now :P (but no, not because of this convertor, hehe)

    If any pros wanna help me out with this, it would be GREATLY appreciated.


    <?php
    // This is an include that I use within another file, and the "$new_hand" variable is already populated with a multi-line block of text

    $rule[0] = "PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\)";

    $rule_replacement[0] = "--------------------<BR><b>Hand Convertor v1.0 -- Poker Stars Tournament</b><BR><BR><b>NL Texas Hold'em, Freeroll - Level \\3</b> (\\4/\\5)<BR><BR><b>Tournament </b>#\\2, <b>Game </b>#\\1, ";

    $rule[1] = "TESTER PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\)";

    $rule_replacement[1] = "TESTER --------------------<BR><b> Hand Convertor v1.0 -- Poker Stars Tournament</b><BR><BR><b>NL Texas Hold'em, Freeroll - Level \\3</b> (\\4/\\5)<BR><BR><b>Tournament </b>#\\2, <b>Game </b>#\\1, ";

    // Split the multi-line variable into an array so that each line is now its own variable
    $hand_test = split("\n", $new_hand);

    $rule_count = count($rule);

    foreach($hand_test as $ht) {

    $count = 0;

    while ($count <= $rule_count) {
    $skibble[$count] = eregi_replace($rule[$count], $rule_replacement[$count], $ht);
    $count++;
    }
    }
    ?>

    At this point I'd like the "$skibble" variable to contain the old "$new_hand" information, except with the replaced, formatted text.

    I'm sure I'm going to be incredibly embarassed when I see what I've done wrong here.

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you provide sample data to back your regex up?

  3. #3
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the first line of the "$new_hand" variable, which matches against the "$rule[0]" regex for sure, as I've been using these same rules in my current converter.

    PokerStars Game #5124378710: Tournament #25456558, Freeroll Hold'em No Limit - Level III (25/50) - 2006/06/01 - 23:03:23 (ET)

    In summary, I'm trying to turn something like this:

    PokerStars Game #5124378710: Tournament #25456558, Freeroll Hold'em No Limit - Level III (25/50) - 2006/06/01 - 23:03:23 (ET)
    Table '25456558 288' 9-max Seat #4 is the button
    Seat 1: Doktor B.S. (8845 in chips)
    Seat 2: woody2081 (1120 in chips)
    Seat 3: Mainic67 (8405 in chips) is sitting out
    Seat 4: j_jo99 (1230 in chips) is sitting out
    Seat 5: ThinkBlueFan (3185 in chips)

    Into something like this (rough formatting, just as an example):

    <b>PokerStars Game #5124378710: Tournament #25456558, Freeroll Hold'em No Limit - Level III (25/50) - 2006/06/01 - 23:03:23 (ET)</b><BR><BR>
    <b>Table '25456558 288'</b> 9-max Seat #4 is the button<BR><BR>
    <b>Seat 1:</b> <i>Doktor B.S.</i> (8845 in chips)
    <b>Seat 2:</b> <i>woody2081</i> (1120 in chips)
    <b>Seat 3:</b> <i>Mainic67</i> (8405 in chips) is sitting out
    <b>Seat 4:</b> <i>j_jo99</i> (1230 in chips) is sitting out
    <b>Seat 5:</b> <i>ThinkBlueFan</i> (3185 in chips)


    This all used to be in one variable, but for some reason the regex replacements wouldn't always work, so I set out on a trek to redo the entire thing using an array instead of the scalar.

    So, it would become:

    $hand_test[0] = "PokerStars Game #5124378710: Tournament #25456558, Freeroll Hold'em No Limit - Level III (25/50) - 2006/06/01 - 23:03:23 (ET)";
    $hand_test[1] = "Table '25456558 288' 9-max Seat #4 is the button";
    $hand_test[2] = "Seat 1: Doktor B.S. (8845 in chips)"
    $hand_test[3] = "Seat 2: woody2081 (1120 in chips)"

    Now, each one of these lines would need to be checked against every one of the rules (there's only 2 'rule' examples in my original post, but there are at least 50 overall. I only included 2 rules so that this was simplified).

    I've been working on this for so long now that my brain's starting to get a bit fried :P But I'm on a trek to get this thing straightened out (I've had tons of people emailing me wondering why my hand histories are all down, so I need to fix it to stop the harassment, hehe).

    Any help is GREATLY appreciated.

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://us2.php.net/manual/en/function.split.php#49130

    you might want to check that out.

  5. #5
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made this change before I started posting on forums, but oddly enough it seems to work the exact opposite for me.

    $hand_test = split("\n", $new_hand);

    - Would split the scalar into an array properly, which each line in a new array variable

    But with

    $hand_test = split("/\n", $new_hand);

    - Every variable in the array contained the entire original scalar

    This is why I'm getting so frustrated :P

    I guess I'll just keep trying different things until something eventually works. Hopefully it takes less than a year, hehe.

  6. #6
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess what I'm not seeing is how you know the problem exists.

  7. #7
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because after the code I have in my first post, I have this code to cycle through the "$skibble" variable and output each variable in the array (just as a test to make sure it was storing the right information).

    foreach($skibble as $sk) {
    echo "$sk<BR><BR>";
    }


    However, when I load the page that this code is on, I get:

    -----
    Warning: ereg_replace(): REG_EMPTY in /PATH_TO_FILE.inc.php on line 28

    Warning: ereg_replace(): REG_EMPTY in /PATH_TO_FILE.inc.php on line 28

    Warning: ereg_replace(): REG_EMPTY in /PATH_TO_FILE.inc.php on line 28

    Warning: ereg_replace(): REG_EMPTY in /PATH_TO_FILE.inc.php on line 28
    -----

    Over and over.

    Maybe I'm just thinking about this in entirely the wrong way, or maybe there's an easier way to do it, I just know that nothing I've tried has worked.

  8. #8
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try doing a:

    PHP Code:
     echo "\$skibble[$count] = eregi_replace({$rule[$count]}{$rule_replacement[$count]}, \$ht)"
    before:

    PHP Code:
    $skibble[$count] = eregi_replace($rule[$count], $rule_replacement[$count], $ht); 

  9. #9
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I added a couple BR's after the \$ht part for formatting sake, but this is what it's giving me now (this is part of it, it keeps going for a while):

    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

    $skibble[2] = eregi_replace(, , $ht)


    Warning: eregi_replace(): REG_EMPTY in /home/greg9d0/public_html/_includes/code/convert_hand_history_pokerstars_tournament.inc.php on line 28
    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

    $skibble[2] = eregi_replace(, , $ht)


    Warning: eregi_replace(): REG_EMPTY in /home/greg9d0/public_html/_includes/code/convert_hand_history_pokerstars_tournament.inc.php on line 28
    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

    $skibble[2] = eregi_replace(, , $ht)


    I have a feeling the logic I'm using when trying to compare each variable (line) of the array with every rule is wrong somehow, and has something to do with the regular expressions.

  10. #10
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $skibble[2] = eregi_replace(, , $ht) <-- ?

  11. #11
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    instead of:

    PHP Code:
    while ($count <= $rule_count
    try:

    PHP Code:
    for ($count $count <= count($rule) ; $count++) 

  12. #12
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    D'oh! That's because I had:

    while ($count <= $rule_count) {

    Instead of

    while ($count <= $rule_count-1) {

    I just fixed that am now getting this over and over:


    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

    $skibble[0] = eregi_replace(posts the ante, posts the ante, $ht)

    $skibble[1] = eregi_replace(PokerStars Game \#([0-9]*): Tournament \#([0-9]*), Freeroll Hold'em No Limit - Level ([0-9a-zA-Z]*) \(([0-9]*)/([0-9]*)\) - ([0-9]*)/([0-9]*)/([0-9]*) - ([0-9]*):([0-9]*):([0-9]*) \(ET\), --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level \3 (\4/\5)

    Tournament #\2, Game #\1, , $ht)

  13. #13
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's because of the echo statement I had you put in. Take that statement out and see what happens.

  14. #14
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL! After I take the echo statement out all I get (literally) is:


    Seat 9: squirt1bad folded before Flop (didn't bet)

    Seat 9: squirt1bad folded before Flop (didn't bet)


    Which is one of the lines that's in the original scalar, but doesn't currently have a rule setup that would match it (I still only have 2 rules in my test code, until I get it working).

    I think I might just try to scour the 'net for some snippet of code that does or works similarly to what I'm trying to do. I have to believe someone out there has tried to do something like this before.

    I think it's time for a smoke, hehe.

  15. #15
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PS - Thanks for tryin', I really appreciate it!

    Been going nuts with this thing, and this is the only forum I've gotten much a response on.

  16. #16
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    o_O

    after the while loop put print_r($skibble), I'm curious as to what it contains.

  17. #17
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After the while end bracket I put " print_r($skibble); exit; " and am getting:


    Array ( [0] => PokerStars Game #5106862273: Tournament #25456538, Freeroll Hold'em No Limit - Level XIV (2000/4000) - 2006/05/31 - 02:10:52 (ET) [1] => --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level XIV (2000/4000)

    Tournament #25456538, Game #5106862273, )

  18. #18
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And without the " exit; " I'm getting:

    Array ( [0] => PokerStars Game #5106862273: Tournament #25456538, Freeroll Hold'em No Limit - Level XIV (2000/4000) - 2006/05/31 - 02:10:52 (ET) [1] => --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level XIV (2000/4000)

    Tournament #25456538, Game #5106862273, ) Array ( [0] => Table '25456538 16' 9-max Seat #2 is the button [1] => Table '25456538 16' 9-max Seat #2 is the button ) Array ( [0] => Seat 1: Doktor B.S. (109536 in chips) is sitting out [1] => Seat 1: Doktor B.S. (109536 in chips) is sitting out ) Array ( [0] => Seat 2: spammond (144198 in chips) [1] => Seat 2: spammond (144198 in chips) ) Array ( [0] => Seat 3: LouisVutton (201503 in chips) [1] => Seat 3: LouisVutton (201503 in chips) ) Array ( [0] => Seat 4: Jester2Dope (85436 in chips) [1] => Seat 4: Jester2Dope (85436 in chips) ) Array ( [0] => Seat 5: trojanzz (107750 in chips) [1] => Seat 5: trojanzz (107750 in chips) ) Array ( [0] => Seat 6: hillyj (467620 in chips) [1] => Seat 6: hillyj (467620 in chips) ) Array ( [0] => Seat 7: BostonChowda (115696 in chips) [1] => Seat 7: BostonChowda (115696 in chips) ) Array ( [0] => Seat 8: Big_Figga (185578 in chips) [1] => Seat 8: Big_Figga (185578 in chips) ) Array ( [0] => Seat 9: squirt1bad (17162 in chips) [1] => Seat 9: squirt1bad (17162 in chips) ) Array ( [0] => Doktor B.S.: posts the ante 200 [1] => Doktor B.S.: posts the ante 200 ) Array ( [0] => spammond: posts the ante 200 [1] => spammond: posts the ante 200 ) Array ( [0] => LouisVutton: posts the ante 200 [1] => LouisVutton: posts the ante 200 ) Array ( [0] => Jester2Dope: posts the ante 200 [1] => Jester2Dope: posts the ante 200 ) Array ( [0] => trojanzz: posts the ante 200 [1] => trojanzz: posts the ante 200 ) Array ( [0] => hillyj: posts the ante 200 [1] => hillyj: posts the ante 200 ) Array ( [0] => BostonChowda: posts the ante 200 [1] => BostonChowda: posts the ante 200 ) Array ( [0] => Big_Figga: posts the ante 200 [1] => Big_Figga: posts the ante 200 ) Array ( [0] => squirt1bad: posts the ante 200 [1] => squirt1bad: posts the ante 200 ) Array ( [0] => LouisVutton: posts small blind 2000 [1] => LouisVutton: posts small blind 2000 ) Array ( [0] => Jester2Dope: posts big blind 4000 [1] => Jester2Dope: posts big blind 4000 ) Array ( [0] => *** HOLE CARDS *** [1] => *** HOLE CARDS *** ) Array ( [0] => Dealt to Doktor B.S. [J1d J1h] [1] => Dealt to Doktor B.S. [J1d J1h] ) Array ( [0] => trojanzz: calls 4000 [1] => trojanzz: calls 4000 ) Array ( [0] => hillyj: folds [1] => hillyj: folds ) Array ( [0] => BostonChowda: calls 4000 [1] => BostonChowda: calls 4000 ) Array ( [0] => Doktor B.S. has returned [1] => Doktor B.S. has returned ) Array ( [0] => Big_Figga: folds [1] => Big_Figga: folds ) Array ( [0] => squirt1bad: folds [1] => squirt1bad: folds ) Array ( [0] => Doktor B.S.: raises 16000 to 20000 [1] => Doktor B.S.: raises 16000 to 20000 ) Array ( [0] => spammond: calls 20000 [1] => spammond: calls 20000 ) Array ( [0] => LouisVutton: folds [1] => LouisVutton: folds ) Array ( [0] => Jester2Dope: folds [1] => Jester2Dope: folds ) Array ( [0] => trojanzz: calls 16000 [1] => trojanzz: calls 16000 ) Array ( [0] => BostonChowda: folds [1] => BostonChowda: folds ) Array ( [0] => *** FLOP *** [81c 41d 21s] [1] => *** FLOP *** [81c 41d 21s] ) Array ( [0] => trojanzz: checks [1] => trojanzz: checks ) Array ( [0] => Doktor B.S.: bets 20000 [1] => Doktor B.S.: bets 20000 ) Array ( [0] => spammond: folds [1] => spammond: folds ) Array ( [0] => trojanzz: calls 20000 [1] => trojanzz: calls 20000 ) Array ( [0] => *** TURN *** [81c 41d 21s] [61c] [1] => *** TURN *** [81c 41d 21s] [61c] ) Array ( [0] => trojanzz: checks [1] => trojanzz: checks ) Array ( [0] => Doktor B.S.: bets 20000 [1] => Doktor B.S.: bets 20000 ) Array ( [0] => trojanzz: calls 20000 [1] => trojanzz: calls 20000 ) Array ( [0] => *** RIVER *** [81c 41d 21s 61c] [71c] [1] => *** RIVER *** [81c 41d 21s 61c] [71c] ) Array ( [0] => trojanzz: bets 47550 and is all-in [1] => trojanzz: bets 47550 and is all-in ) Array ( [0] => Doktor B.S.: calls 47550 [1] => Doktor B.S.: calls 47550 ) Array ( [0] => *** SHOW DOWN *** [1] => *** SHOW DOWN *** ) Array ( [0] => trojanzz: shows [Q1h Q1c] (a pair of Queens) [1] => trojanzz: shows [Q1h Q1c] (a pair of Queens) ) Array ( [0] => Doktor B.S.: shows [J1d J1h] (a pair of Jacks) [1] => Doktor B.S.: shows [J1d J1h] (a pair of Jacks) ) Array ( [0] => trojanzz collected 246900 from pot [1] => trojanzz collected 246900 from pot ) Array ( [0] => *** SUMMARY *** [1] => *** SUMMARY *** ) Array ( [0] => Total pot 246900 | Rake 0 [1] => Total pot 246900 | Rake 0 ) Array ( [0] => Board [81c 41d 21s 61c 71c] [1] => Board [81c 41d 21s 61c 71c] ) Array ( [0] => Seat 1: Doktor B.S. showed [J1d J1h] and lost with a pair of Jacks [1] => Seat 1: Doktor B.S. showed [J1d J1h] and lost with a pair of Jacks ) Array ( [0] => Seat 2: spammond (button) folded on the Flop [1] => Seat 2: spammond (button) folded on the Flop ) Array ( [0] => Seat 3: LouisVutton (small blind) folded before Flop [1] => Seat 3: LouisVutton (small blind) folded before Flop ) Array ( [0] => Seat 4: Jester2Dope (big blind) folded before Flop [1] => Seat 4: Jester2Dope (big blind) folded before Flop ) Array ( [0] => Seat 5: trojanzz showed [Q1h Q1c] and won (246900) with a pair of Queens [1] => Seat 5: trojanzz showed [Q1h Q1c] and won (246900) with a pair of Queens ) Array ( [0] => Seat 6: hillyj folded before Flop (didn't bet) [1] => Seat 6: hillyj folded before Flop (didn't bet) ) Array ( [0] => Seat 7: BostonChowda folded before Flop [1] => Seat 7: BostonChowda folded before Flop ) Array ( [0] => Seat 8: Big_Figga folded before Flop (didn't bet) [1] => Seat 8: Big_Figga folded before Flop (didn't bet) ) Array ( [0] => Seat 9: squirt1bad folded before Flop (didn't bet) [1] => Seat 9: squirt1bad folded before Flop (didn't bet) ) Seat 9: squirt1bad folded before Flop (didn't bet)

    Seat 9: squirt1bad folded before Flop (didn't bet)

  19. #19
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hrmm, ok, so where are you echo-ing out the $skibble stuff?

  20. #20
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After the code in my original post I just have:

    foreach($skibble as $sk) {
    echo "$sk<BR><BR>";
    }

    To cycle through the $skibble array and print out each of the variables.

    Just realized I didn't comment this out after putting the print_r line in. With this foreach commented out, I'm getting:

    Array ( [0] => PokerStars Game #5106862273: Tournament #25456538, Freeroll Hold'em No Limit - Level XIV (2000/4000) - 2006/05/31 - 02:10:52 (ET) [1] => --------------------
    Hand Convertor v1.0 -- Poker Stars Tournament

    NL Texas Hold'em, Freeroll - Level XIV (2000/4000)

    Tournament #25456538, Game #5106862273, ) Array ( [0] => Table '25456538 16' 9-max Seat #2 is the button [1] => Table '25456538 16' 9-max Seat #2 is the button ) Array ( [0] => Seat 1: Doktor B.S. (109536 in chips) is sitting out [1] => Seat 1: Doktor B.S. (109536 in chips) is sitting out ) Array ( [0] => Seat 2: spammond (144198 in chips) [1] => Seat 2: spammond (144198 in chips) ) Array ( [0] => Seat 3: LouisVutton (201503 in chips) [1] => Seat 3: LouisVutton (201503 in chips) ) Array ( [0] => Seat 4: Jester2Dope (85436 in chips) [1] => Seat 4: Jester2Dope (85436 in chips) ) Array ( [0] => Seat 5: trojanzz (107750 in chips) [1] => Seat 5: trojanzz (107750 in chips) ) Array ( [0] => Seat 6: hillyj (467620 in chips) [1] => Seat 6: hillyj (467620 in chips) ) Array ( [0] => Seat 7: BostonChowda (115696 in chips) [1] => Seat 7: BostonChowda (115696 in chips) ) Array ( [0] => Seat 8: Big_Figga (185578 in chips) [1] => Seat 8: Big_Figga (185578 in chips) ) Array ( [0] => Seat 9: squirt1bad (17162 in chips) [1] => Seat 9: squirt1bad (17162 in chips) ) Array ( [0] => Doktor B.S.: posts the ante 200 [1] => Doktor B.S.: posts the ante 200 ) Array ( [0] => spammond: posts the ante 200 [1] => spammond: posts the ante 200 ) Array ( [0] => LouisVutton: posts the ante 200 [1] => LouisVutton: posts the ante 200 ) Array ( [0] => Jester2Dope: posts the ante 200 [1] => Jester2Dope: posts the ante 200 ) Array ( [0] => trojanzz: posts the ante 200 [1] => trojanzz: posts the ante 200 ) Array ( [0] => hillyj: posts the ante 200 [1] => hillyj: posts the ante 200 ) Array ( [0] => BostonChowda: posts the ante 200 [1] => BostonChowda: posts the ante 200 ) Array ( [0] => Big_Figga: posts the ante 200 [1] => Big_Figga: posts the ante 200 ) Array ( [0] => squirt1bad: posts the ante 200 [1] => squirt1bad: posts the ante 200 ) Array ( [0] => LouisVutton: posts small blind 2000 [1] => LouisVutton: posts small blind 2000 ) Array ( [0] => Jester2Dope: posts big blind 4000 [1] => Jester2Dope: posts big blind 4000 ) Array ( [0] => *** HOLE CARDS *** [1] => *** HOLE CARDS *** ) Array ( [0] => Dealt to Doktor B.S. [J1d J1h] [1] => Dealt to Doktor B.S. [J1d J1h] ) Array ( [0] => trojanzz: calls 4000 [1] => trojanzz: calls 4000 ) Array ( [0] => hillyj: folds [1] => hillyj: folds ) Array ( [0] => BostonChowda: calls 4000 [1] => BostonChowda: calls 4000 ) Array ( [0] => Doktor B.S. has returned [1] => Doktor B.S. has returned ) Array ( [0] => Big_Figga: folds [1] => Big_Figga: folds ) Array ( [0] => squirt1bad: folds [1] => squirt1bad: folds ) Array ( [0] => Doktor B.S.: raises 16000 to 20000 [1] => Doktor B.S.: raises 16000 to 20000 ) Array ( [0] => spammond: calls 20000 [1] => spammond: calls 20000 ) Array ( [0] => LouisVutton: folds [1] => LouisVutton: folds ) Array ( [0] => Jester2Dope: folds [1] => Jester2Dope: folds ) Array ( [0] => trojanzz: calls 16000 [1] => trojanzz: calls 16000 ) Array ( [0] => BostonChowda: folds [1] => BostonChowda: folds ) Array ( [0] => *** FLOP *** [81c 41d 21s] [1] => *** FLOP *** [81c 41d 21s] ) Array ( [0] => trojanzz: checks [1] => trojanzz: checks ) Array ( [0] => Doktor B.S.: bets 20000 [1] => Doktor B.S.: bets 20000 ) Array ( [0] => spammond: folds [1] => spammond: folds ) Array ( [0] => trojanzz: calls 20000 [1] => trojanzz: calls 20000 ) Array ( [0] => *** TURN *** [81c 41d 21s] [61c] [1] => *** TURN *** [81c 41d 21s] [61c] ) Array ( [0] => trojanzz: checks [1] => trojanzz: checks ) Array ( [0] => Doktor B.S.: bets 20000 [1] => Doktor B.S.: bets 20000 ) Array ( [0] => trojanzz: calls 20000 [1] => trojanzz: calls 20000 ) Array ( [0] => *** RIVER *** [81c 41d 21s 61c] [71c] [1] => *** RIVER *** [81c 41d 21s 61c] [71c] ) Array ( [0] => trojanzz: bets 47550 and is all-in [1] => trojanzz: bets 47550 and is all-in ) Array ( [0] => Doktor B.S.: calls 47550 [1] => Doktor B.S.: calls 47550 ) Array ( [0] => *** SHOW DOWN *** [1] => *** SHOW DOWN *** ) Array ( [0] => trojanzz: shows [Q1h Q1c] (a pair of Queens) [1] => trojanzz: shows [Q1h Q1c] (a pair of Queens) ) Array ( [0] => Doktor B.S.: shows [J1d J1h] (a pair of Jacks) [1] => Doktor B.S.: shows [J1d J1h] (a pair of Jacks) ) Array ( [0] => trojanzz collected 246900 from pot [1] => trojanzz collected 246900 from pot ) Array ( [0] => *** SUMMARY *** [1] => *** SUMMARY *** ) Array ( [0] => Total pot 246900 | Rake 0 [1] => Total pot 246900 | Rake 0 ) Array ( [0] => Board [81c 41d 21s 61c 71c] [1] => Board [81c 41d 21s 61c 71c] ) Array ( [0] => Seat 1: Doktor B.S. showed [J1d J1h] and lost with a pair of Jacks [1] => Seat 1: Doktor B.S. showed [J1d J1h] and lost with a pair of Jacks ) Array ( [0] => Seat 2: spammond (button) folded on the Flop [1] => Seat 2: spammond (button) folded on the Flop ) Array ( [0] => Seat 3: LouisVutton (small blind) folded before Flop [1] => Seat 3: LouisVutton (small blind) folded before Flop ) Array ( [0] => Seat 4: Jester2Dope (big blind) folded before Flop [1] => Seat 4: Jester2Dope (big blind) folded before Flop ) Array ( [0] => Seat 5: trojanzz showed [Q1h Q1c] and won (246900) with a pair of Queens [1] => Seat 5: trojanzz showed [Q1h Q1c] and won (246900) with a pair of Queens ) Array ( [0] => Seat 6: hillyj folded before Flop (didn't bet) [1] => Seat 6: hillyj folded before Flop (didn't bet) ) Array ( [0] => Seat 7: BostonChowda folded before Flop [1] => Seat 7: BostonChowda folded before Flop ) Array ( [0] => Seat 8: Big_Figga folded before Flop (didn't bet) [1] => Seat 8: Big_Figga folded before Flop (didn't bet) ) Array ( [0] => Seat 9: squirt1bad folded before Flop (didn't bet) [1] => Seat 9: squirt1bad folded before Flop (didn't bet) )


    So it looks like my foreach statement (above) was only outputting:

    Seat 9: squirt1bad folded before Flop (didn't bet)

  21. #21
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hold on a sec



    Ok I'm done. Now then, back to work. I'm gonna go back like 20 steps now. Is this :

    1) PokerStars Game #5124378710: Tournament #25456558, Freeroll Hold'em No Limit - Level III (25/50) - 2006/06/01 - 23:03:23 (ET)
    2) Table '25456558 288' 9-max Seat #4 is the button
    3) Seat 1: Doktor B.S. (8845 in chips)

    The only format of data you'll be working with? Are there more?

  22. #22
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For now, yes. Below is the example of a full hand history that I'm trying to convert. I'm basically trying to turn it from an ugly text mess into a nicely formatted version to be posted on my site.

    I'm eventually going to be reconverting my other hand histories converters, but for now (until I get the new coding down) I'm just working on the Poker Stars Tournament hands.

    This is what they look like straight from the site, and I'm trying to get it so I can just copy/paste it into the "new article" text field on my site admin, hit submit, and have it convert the hand history for me. I post a lot of them, so I'm trying to automate the process as much as possible.


    PokerStars Game #5106862273: Tournament #25456538, Freeroll Hold'em No Limit - Level XIV (2000/4000) - 2006/05/31 - 02:10:52 (ET)
    Table '25456538 16' 9-max Seat #2 is the button
    Seat 1: Doktor B.S. (109536 in chips) is sitting out
    Seat 2: spammond (144198 in chips)
    Seat 3: LouisVutton (201503 in chips)
    Seat 4: Jester2Dope (85436 in chips)
    Seat 5: trojanzz (107750 in chips)
    Seat 6: hillyj (467620 in chips)
    Seat 7: BostonChowda (115696 in chips)
    Seat 8: Big_Figga (185578 in chips)
    Seat 9: squirt1bad (17162 in chips)
    Doktor B.S.: posts the ante 200
    spammond: posts the ante 200
    LouisVutton: posts the ante 200
    Jester2Dope: posts the ante 200
    trojanzz: posts the ante 200
    hillyj: posts the ante 200
    BostonChowda: posts the ante 200
    Big_Figga: posts the ante 200
    squirt1bad: posts the ante 200
    LouisVutton: posts small blind 2000
    Jester2Dope: posts big blind 4000
    *** HOLE CARDS ***
    Dealt to Doktor B.S. [J1d J1h]
    trojanzz: calls 4000
    hillyj: folds
    BostonChowda: calls 4000
    Doktor B.S. has returned
    Big_Figga: folds
    squirt1bad: folds
    Doktor B.S.: raises 16000 to 20000
    spammond: calls 20000
    LouisVutton: folds
    Jester2Dope: folds
    trojanzz: calls 16000
    BostonChowda: folds
    *** FLOP *** [81c 41d 21s]
    trojanzz: checks
    Doktor B.S.: bets 20000
    spammond: folds
    trojanzz: calls 20000
    *** TURN *** [81c 41d 21s] [61c]
    trojanzz: checks
    Doktor B.S.: bets 20000
    trojanzz: calls 20000
    *** RIVER *** [81c 41d 21s 61c] [71c]
    trojanzz: bets 47550 and is all-in
    Doktor B.S.: calls 47550
    *** SHOW DOWN ***
    trojanzz: shows [Q1h Q1c] (a pair of Queens)
    Doktor B.S.: shows [J1d J1h] (a pair of Jacks)
    trojanzz collected 246900 from pot
    *** SUMMARY ***
    Total pot 246900 | Rake 0
    Board [81c 41d 21s 61c 71c]
    Seat 1: Doktor B.S. showed [J1d J1h] and lost with a pair of Jacks
    Seat 2: spammond (button) folded on the Flop
    Seat 3: LouisVutton (small blind) folded before Flop
    Seat 4: Jester2Dope (big blind) folded before Flop
    Seat 5: trojanzz showed [Q1h Q1c] and won (246900) with a pair of Queens
    Seat 6: hillyj folded before Flop (didn't bet)
    Seat 7: BostonChowda folded before Flop
    Seat 8: Big_Figga folded before Flop (didn't bet)
    Seat 9: squirt1bad folded before Flop (didn't bet)

  23. #23
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm, ok. I have to sleep now, but I'm going to take a look tommorow. I have this deep inner fire thingy going on and it's time to put it out (grr?).

  24. #24
    SitePoint Member
    Join Date
    Jul 2004
    Location
    Surrey, BC
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all your help! But, I think I might've just made a big breakthrough based on some responses I got on another forum. Just having another weird problem with it now, but I'm sure I'll be able to iron it out.

    http://phpbuilder.com/board/showthre...1#post10731252

    I really appreciate all your help! Just didn't want you to waste any more of your time looking into this further.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •