Ohhhhh Okay So it must be end('$mesg') because $mesg is an array of messages.. That makes perfect sense, I don't know why I thought otherwise :P
Okay, so it works then. Cool ;)
It may be better used like this:
PHP Code:
function give_response($mesg,$catch,$response)
{
$last = (string) 'hey!';
$mesg = (string) $mesg;
$catch = (array) $catch;
$response = (array) $response;
$default = array (
'speak english you dumb cunt',
"I can't understand a word you're saying.."
);
if(eregi('hey',$mesg)>0)
{
return $last;
}
else if(strlen($mesg)>0)
{
for($i=0;$i<count($catch);$i++)
{
if(eregi($catch[$i],$mesg)>0)
{
return $response[$i];
}
}
} else return $default[ rand(0, (count($default)-1) ) ];
}
$catch = array (
'1',
'2',
'fuck you',
'fuck me',
'im not fat sorry',
'lol'
);
$response = array (
'M3GA@stoned.com, johnny10561@hotmail.com',
'HotelunderSeige',
'you to punji',
'not your fat ass',
'and im human',
'go back to thailand commi, nothing is funny there'
);
$new_message = give_response(end($mesg),$catch,$response);
This way the arrays are a bit more flexible. So if you decide to switch to MySQL for storage, it will be more easy because you can just add the assiciative array returned from `mysql_fetch_array()` or `mysql_fetch_assoc()`.
Good luck ;)
Edit:
You might consider making $default outside the function as well :P I forgot about that.. - It's another thing you might want in the db