PDA

View Full Version : working with explode()


king2k5
12-02-2007, 09:53 PM
I have this for private messaging system in my chat..

$check = explode(" ", $babble);

if($check[1] == '/pm'){
$date = date("M dS h:i:s a");
$to = $check[2];
$message2 = $check[3];
$babble4 = strip_tags($message2);
$babble3 = str_replace($search, $replace, $babble4);
mysql_query("INSERT INTO babble2 SET id='',posttime='$date',author='$username (PM)',babble=' ".$babble3."',view='$to'");

}

$to is the username of the person you are sending it to
$message2 is the "message" which there lies the problem..
$username is the person it is from.. so..

/pm king2k5 test this

$to = king2k5
$message2 = test

thats the problem.. after the username i dont want it to explode the spaces anymore.. is there a way around this?

Mwnciau
12-02-2007, 10:59 PM
The 3rd parameter of explode() limits the explosions

explode(" ", $babble, 3);