PDA

View Full Version : Php Code Help


insanctus
03-06-2003, 01:06 PM
I am trying to learn more about php . I posted this code in another part tryin to get input on the hack I was hacking.

Seeing as it is also something I very much want to understand why it does not work I will try in this part.

// END CONFIG
$ttb_username="whatever";
$usernamelen = strlen($ttb_username);
if ($ttb==1 AND rand(1,100)<=$ttb_weighting AND $ttb_username=substr($message, 0, $usernamelen) AND $bbuserinfo[userid]!=$ttb_memberid) {gottb();};
$message=substr_replace($message, "", 0, $usernamelen);

Please someone explain why it does not take parse the $message

I am used to visual basics and some of php makes sence just others do not.

Thanks in advance.

Sebastian
03-06-2003, 02:33 PM
$message has no value (from what you posted) .. you need to assign a value to it.

insanctus
03-06-2003, 02:40 PM
Assume $message="whatever how are you all today";
The above code should take out the whatever in the beggining.

Sebastian
03-06-2003, 02:53 PM
you can use explode(); (http://www.php.net/explode)

it works well for what you are trying to do.

or try this:


$message = substr( trim( $message ) , 0 , $message );

insanctus
03-06-2003, 03:25 PM
Explode seems to make more functions then needed.

There is not a way just to take out first word in the sentence?

insanctus
03-06-2003, 03:31 PM
Wait n/m I got it thanks to your example.

Thank you for the help. It is hard learning all this when I am used to a dif lang:)