$pharray = array("php","the best language ever");
preg_match("/(?<=What is )(\w+)(?:\?)/",$question,$matches);
if (in_array($matches[0],$phparray)){
// your stuff here
}

Regards,
Andrey

----- Original Message ----- 
From: "Leif K-Brooks" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 16, 2002 12:54 AM
Subject: [PHP] Seeing if a value matches anything in an array


> I'm trying to build some sort of AI chat bot in php (yes, I know I'm crazy).
> To do this, I need some way to check for the presence of any value from an
> array.  Example:
> 
> $pharray = array("php","the best language ever");
> if($question == "What is ".anything_in_array_function($phparray)."?"){
> print "Php is a programming language used mostly as a web scripting
> language.  (put some more stuff about php here)";
> }
> 
> What is the best way to do something like this? 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to