The following you can use to split the text up
Method 1 use array functions a bit easier
Read the line into a string
$chat_line = "<BMWGUY71> ; [XXX.XXX.XXX.XXX] ; [MM-DD-YYYY HH:MM:SS] ; hey what's up everyone?
";
break apart the string into an array using the explode method. Since each part is seperated by a semi colon you can split the string that by the semi-colon.
array explode (string separator, string string [, int limit])
$chat_array = explode( ";", $chat_line );
this will create an array
$chat_array[0] = "<BMWGUY71> "
$chat_array[1] = "[XXX.XXX.XXX.XXX] "
$chat_array[2] = " [MM-DD-YYYY HH:MM:SS] "
$chat_array[3] = "hey what's up everyone? "
Next combine the items you want
//combine the parts you want
$printable_chat = $chat_array[0] . " " . $chat_array[3];
echo $printable_chat;
Method 2, use string functions to break up text.
Read the line into a string
$chat_line = "<BMWGUY71> ; [XXX.XXX.XXX.XXX] ; [MM-DD-YYYY HH:MM:SS] ; hey what's up everyone?
";
if so you can search for the ; store the first part into a string and contactinate the 2nd ; to the end with that
the following should work
strpos returns the positition of an item in a string. the sytanx is the following
int strpos (string haystack, string needle [, int offset])
// get position of first semi colon
$first_semi = int strpos ($chat_line, ";");
Next use the substring function to extract the beginning of the string
string substr (string string, int start [, int length])
// store only beginning of chat in a temp string
$printable_chat = substr( $chat_line, 0, $first_semi);
Next get the position of hte third semi-colon, use the first semi colon position as the offset
// get position of next semi using the first semi as the offset
$second_semi = int strpos ($chat_line, ";", $first_semi);
// get position of third semi using the second semi as the offset
$third_semi = int strpos ($chat_line, ";", $second_semi);
Next get the substring of the last part of the chat line and combine it with the first part
// get last part of the chat line and combine with first part
$printable_chat .= substr( $chat_line, $third_semi );
the complete code for method 2 is as follows
// get position of first semi colon
$first_semi = int strpos ($chat_line, ";");
// store only beginning of chat in a temp string
$printable_chat = substr( $chat_line, 0, $first_semi);
// get position of next semi using the first semi as the offset
$second_semi = int strpos ($chat_line, ";", $first_semi);
// get position of third semi using the second semi as the offset
$third_semi = int strpos ($chat_line, ";", $second_semi);
// get last part of the chat line and combine with first part
$printable_chat .= substr( $chat_line, $third_semi );
echo $third_semi;