Page 1 of 1

Problem in working with LogsHandHistory and Rake

Posted: Wed Apr 22, 2015 12:42 pm
by aminwxy
hi
we are coding a PHP to use API and retrieve Rake from LogsHandHistory
so the result is fine and we get it,
but i need some specific Data , such as The name of the winner of one pot and the rake Number of that pot.

how can i retrive theme with and extracting the numbers ?
i want to put theme in our database and do some work with it

Re: Problem in working with LogsHandHistory and Rake

Posted: Wed Apr 22, 2015 12:58 pm
by Kent Briggs
aminwxy wrote:how can i retrive theme with and extracting the numbers ?
i want to put theme in our database and do some work with it
You have to parse the data line by line looking for the key words that match the data you want to extract. For example, lines starting with "Hand #" indicate the beginning of the hand, lines starting with "** Deck **" indicate the end of the hand. Look for "xxxxxx wins " or "xxxxxx splits " to see hand winner. Lines starting with "Rake (" contain the rake info, etc. Hands with side pots may have multiple rakes and winners.

Re: Problem in working with LogsHandHistory and Rake

Posted: Wed Apr 22, 2015 1:17 pm
by aminwxy
so if i use "Substr" PHP Function ,as it is in the Api Example used, i cant extract the exact data,
for example :
$hand_winner = Substr($api[25],0,1) ;
output is not what we want !
and also if the username is 5 charactre or 9 character , "xxxxxx wins " or "xxxxxx splits " is miss match data
is there any alternative Function?

Re: Problem in working with LogsHandHistory and Rake

Posted: Wed Apr 22, 2015 1:28 pm
by Kent Briggs
aminwxy wrote:and also if the username is 5 charactre or 9 character , "xxxxxx wins " or "xxxxxx splits " is miss match data
is there any alternative Function?
This is basic string manipulation. Use a function like strpos() to find the position of " wins " in the line. Then use Substr() to pull out the name starting from the first position and ending in the position just before " wins ".

Re: Problem in working with LogsHandHistory and Rake

Posted: Thu Apr 23, 2015 3:50 am
by aminwxy
ok thanks , i got that and Find The way,
only one problem remain,

if i want to find the exact line number of "Rake" and "win" ,
can i also using this method ?
because Line number in the result is different , for example $api[25] return different data in the result of all Hand.

Re: Problem in working with LogsHandHistory and Rake

Posted: Thu Apr 23, 2015 9:29 am
by Kent Briggs
aminwxy wrote:if i want to find the exact line number of "Rake" and "win" ,
can i also using this method ?
because Line number in the result is different , for example $api[25] return different data in the result of all Hand.
All the data is returned in an array when you use the JSON option in the API call. Then you just loop through the array, examining each line as you go. The HandHistory example of the API Examples page shows how that is done:

http://www.briggsoft.com/docs/pmavens/A ... nd_history

Code: Select all

echo "<pre>\n";
for ($i = 0; $i < count($api -> Data); $i++) echo $api -> Data[$i] . "\n";
echo "</pre>\n"; 

Re: Problem in working with LogsHandHistory and Rake

Posted: Fri May 15, 2015 10:24 am
by aminwxy
Hello again, and Thanks for your help and Reply,
I have one more question

Please look at this line :

"Rake (9000) Pot (450000) Players (UYT789: 225000, MASTER: 225000)"

How can i get this information from this line :
Rake , number of player and name of players ?

thank you

Re: Problem in working with LogsHandHistory and Rake

Posted: Fri May 15, 2015 11:18 am
by Kent Briggs
aminwxy wrote: "Rake (9000) Pot (450000) Players (UYT789: 225000, MASTER: 225000)"

How can i get this information from this line :
Rake , number of player and name of players ?
Just take the string apart systematically using the various PHP string functions available. Locate the first "(" and first ")". Pull the rake out in between those. Locate the second "(" and second ")". Pull the pot number out between those. Same with the player names. Look for the parentheses, colons, and commas and pull out the names and corresponding amounts until you reach the closing ")".

Re: Problem in working with LogsHandHistory and Rake

Posted: Fri May 15, 2015 3:28 pm
by aminwxy
i can get the rake number easily with a PHp functiona to find string between two character
but about the Player name , when it is 3 or more Player like this :

Rake (11548) Pot (577404) Players (UYT789: 140412, MR-77: 218496, Lady65: 19526, MASTER: 218496)

so i dont Understand how to get them, i can only retrive player one and two with find string between "(" and ":" also string between "," nad ":"

so Player 3 and 4 MASTER , Lady65 is not retrieve :((

any solution?

Re: Problem in working with LogsHandHistory and Rake

Posted: Fri May 15, 2015 3:57 pm
by Kent Briggs
aminwxy wrote: Rake (11548) Pot (577404) Players (UYT789: 140412, MR-77: 218496, Lady65: 19526, MASTER: 218496)
so i dont Understand how to get them, i can only retrive player one and two with find string between "(" and ":" also string between "," nad ":"
Find the start of the first player name. Then run a loop that pulls out the name and amount. If the character after amount is a comma, you repeat the loop and grab another name and amount. If it's a ")", end the loop and stop.