Re: Seeing if a value matches anything in an array

From: Date: Tue, 16 Apr 2002 08:12:01 +0000
Subject: Re: Seeing if a value matches anything in an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93145@lists.php.net to get a copy of this message
$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" <eurleif@buyer-brokerage.com> To: <php-general@lists.php.net> 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 > >

« previous php.general (#93145) next »