• Welcome to Valhalla Legends Archive.
 

PHP Help with Battle.net

Started by UnderCover, November 16, 2003, 06:51 PM

Previous topic - Next topic

UnderCover

explode ( string separator, string string [, int limit])


Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string separator. If limit is set, the returned array will contain a maximum of limit elements with the last element containing the rest of string.

thats wut php.net said

so would i put

explode("\n", $data, "not sure wut goes here?");

Spht

Third parameter looks optional.

If limit is set, the returned array will contain a maximum of limit elements with the last element containing the rest of string.

UnderCover

#47
yes but im not sure how to stop the cutting of the data.

I couldn't really understand wut grok said...

EDIT:

does anyone know how ot the the ending string of explode?
the way im doing it its causign a lot of cutting to happen....

Grok

Quote from: UnderCover on November 22, 2003, 12:19 PM
yes but im not sure how to stop the cutting of the data.

I couldn't really understand wut grok said...

Could you explain your code, as posted?  That would go a long way to you understanding what I said.  I'm sure of it.

UnderCover

yeh this code



<?
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//COPYRIGHT www.saclans.com 2003-2004 ;;
//Written By: -][SA][-UnderCover      ;;
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

//;;;;;;;;;;;;;;;;;;;;;;
//;;Battle.net Replies;;
//;;USER              ;;
//;;NAME              ;;
//;;CHANNEL           ;;
//;;INFO              ;;
//;;ERROR             ;;
//;;EMOTE             ;;
//;;JOIN              ;;
//;;LEAVE             ;;
//;;TALK              ;;
//;;WHISPER           ;;
//;;NULL              ;;
//;;;;;;;;;;;;;;;;;;;;;;

$ip = "useast.battle.net";
$port = "6112";

$server = fsockopen("tcp://".$ip, $port , $errno, $errstr , 30);
$SocStatus = socket_get_status($server);

fputs($server, "\x03$username\r\n\x03$password\r\n");

while($data2 = fread($server, 5000)) {
$explode = explode("\n", $data2);
$i = "-1";
$count = count($explode);
while($i <= $count) {
$i++;
$info = "<li>$explode[$i]</li>";
echo $info;
}
}


?>


first it connects to bnet, then it sends the login stuff, then it reads from the socket.  Im trying tog et it to filter out the data so when it says CHANNEL it would fileter out the channel name and so on.

Grok

Explain line by line how your loop works.

UnderCover

<?
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//COPYRIGHT www.saclans.com 2003-2004 ;;
//Written By: -][SA][-UnderCover      ;;
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

//;;;;;;;;;;;;;;;;;;;;;;
//;;Battle.net Replies;;
//;;USER              ;;
//;;NAME              ;;
//;;CHANNEL           ;;
//;;INFO              ;;
//;;ERROR             ;;
//;;EMOTE             ;;
//;;JOIN              ;;
//;;LEAVE             ;;
//;;TALK              ;;
//;;WHISPER           ;;
//;;NULL              ;;
//;;;;;;;;;;;;;;;;;;;;;;

$ip = "useast.battle.net";
$port = "6112";

$server = fsockopen("tcp://".$ip, $port , $errno, $errstr , 30);
$SocStatus = socket_get_status($server);

$username = "lSAl-Bot";
$password = "new";

fputs($server, "\x03$username\r\n\x03$password\r\n");

// while its gets data from the server
while($data2 = fread($server, 5000)) {
$explode = explode("\n", $data2); ---explode the data
$i = "-1"; give a number
$count = count($explode); count the exploded data
while($i <= $count) { while the number is less than count
$i++; add the number
$info = "<li>$explode[$i]</li>"; show the exploded information 0 , 1, 2 etc
echo $info; show the information
}
}
close loops

?>


hope fully this helped

Grok

No, it didn't.  I am not convinced you understand the program.  I want you to explain it in terms of the data, not in terms of the function names.

Just document this loop:


while($data2 = fread($server, 5000)) {
$explode = explode("\n", $data2);
$i = "-1";
$count = count($explode);
while($i <= $count) {
$i++;
$info = "<li>$explode[$i]</li>";
echo $info;
}
}

UnderCover

#53

while($data2 = fread($server, 5000)) { this talks to the sevrer and retrives data from it
$explode = explode("\n", $data2); this seperates the data by \n
$i = "-1";
$count = count($explode); this counts the seperated data
while($i <= $count) { this takes  a number and as long  as it is less than the counted data it will stay true
$i++;
$info = "<li>$explode[$i]</li>"; this presents the data by array [1] [2] etc
echo $info; this shows the data
}
}


Edit - fixed your format tag.

UnderCover

#54
spht did you edit my post??

wut did you fix if you edited...

EDIT:

its still cutting of data...

does anyone know wut im doing wrong?

Spht

Quote from: UnderCover on November 22, 2003, 06:29 PM
spht did you edit my post??

wut did you fix if you edited...

You should always look at your post after you post something before wandering off. You had a couple empty quote tags at the top, then the code you pasted (which wasn't between code tag), and then empty code tags at end.

UnderCover

ohh sorry :) but do you know how to get all the data instead of just a segment?

Arta

Oh for the love of God. You've asked the same question about 4 times now and the same answer has been given in each case.

btw: It's WHAT. W-H-A-T. What.


CrAzY

If you dont know what Explode does... it Separates X amonunt of strings by the set string.  An example would be " ", a space.  $blah = explode(" ", "Hello World");.  After this you break apart Hello and World disregaurding the space.  Now you can define them into strings :-).  $booo = $blah[0];.  or $boo is = to Hello.  
CrAzY

|