![]() |
PHP Guys - Help
I'm trying to spit out some poor code and am curious if I can improve my method.
In a funciton, I'm searching a string for several different strings. If it is found, I want to return "Found". $valxx=in_string("variable1",$input); if ($valxxhahahaha"true") { $returnval="Found"; return($returnval); } $valxx=in_string("variable2",$input); if ($valxxhahahaha"true") { $returnval="Found"; return($returnval); } $valxx=in_string("variable3",$input); if ($valxxhahahaha"true") { $returnval="Found"; return($returnval); } $valxx=in_string("variable4",$input); if ($valxxhahahaha"true") { $returnval="Found"; return($returnval); } Is there any way I can load the "variable1,variable2" into an array and do it in a single statement? Thanks |
can you write it without the 'hahahaha' crap somehow?
|
post your icq
|
The hahah stuff is just '=true' with double equals.
Asher, I hit you up on your ICQ. |
Hit me up 243680554
|
Quote:
|
$input = 'this input contains variable1...';
$array = array('variable1', 'variable2', 'variable3'); if(preg_match('/'.implode('|', $array).'/', $input)) { echo "Found"; } That is it :-) |
All times are GMT -7. The time now is 10:36 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123