WOOHOO! So much progress!!
I was right, it was an escaping issue, but I'm having another very weird problem now.
When I assign the array manually, it works fine, but when I try to run the search and replace on the array I create from my original scalar, it doesn't work.
NOTE: The two snippets of green code are identical in both examples.
Manual code that works
[INDENT]$hand_test = array(
"PokerStars Game #5106862273: Tournament #25456538, Freeroll Hold'em No Limit - Level XIV (2000/4000) - 2006/05/31 - 02:10:52 (ET)",
"NAME folds",
"NAME checks",
"NAME checks",
" THE TURN ",
"NAME checks",
"NAME folds",
"NAME folds");
$patterns = array(
'/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)$/' => '--------------------<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<BR>--------------------',
'/(.) checks$/' => '<i><b>$1</b> checks</i>',
'/THE TURN/' => '<b>$0</b>');
$search = array_keys($patterns);
$replace = array_values($patterns);
$skibble = preg_replace($search, $replace, $hand_test);
foreach($skibble as $sk) {
echo "$sk<BR><BR><BR>";
}
exit;[/INDENT]
----------
Scalar to Array code that doesn't work
[INDENT]$hand_test = split("\n", $new_hand);
$patterns = array(
'/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)$/' => '--------------------<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<BR>--------------------',
'/(.) checks$/' => '<i><b>$1</b> checks</i>',
'/THE TURN/' => '<b>$0</b>');
$search = array_keys($patterns);
$replace = array_values($patterns);
$skibble = preg_replace($search, $replace, $hand_test);
foreach($skibble as $sk) {
echo "$sk<BR><BR><BR>";
}
exit;[/INDENT]
However, when I just print out the new "$hand_test" array like below, it looks just fine to me, so it seems like $hand_test[0] should be the exact same as the first array entry in the manual example above, but for some reason it doesn't match.
[INDENT]$hand_test = split("\n", $new_hand);
foreach($hand_test as $ht) {
echo "$ht<BR><BR><BR>";
}
exit;[/INDENT]
Outputs:
[INDENT]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
(etc.)[/INDENT]
Alternatively, if I just use the print_r function instead of the foreach in the last example, like so, this is what it shows:
[INDENT]$hand_test = split("\n", $new_hand);
print_r($hand_test);
exit;[/INDENT]
Outputs (hacked off after [5] to save space here)
Array ( [0] => PokerStars Game #5106862273: Tournament #25456538, Freeroll Hold'em No Limit - Level XIV (2000/4000) - 2006/05/31 - 02:10:52 (ET) [1] => Table '25456538 16' 9-max Seat #2 is the button [2] => Seat 1: Doktor B.S. (109536 in chips) is sitting out [3] => Seat 2: spammond (144198 in chips) [4] => Seat 3: LouisVutton (201503 in chips) [5] => Seat 4: Jester2Dope (85436 in chips)
Is there something I'm missing here?
Ok, it's 4:30am, I think it's time I stopped working on this and got some sleep 😛