GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Guys - Help (https://gfy.com/showthread.php?t=426414)

Dusen 02-03-2005 06:24 AM

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

who 02-03-2005 06:35 AM

can you write it without the 'hahahaha' crap somehow?

Ash@phpFX 02-03-2005 06:36 AM

post your icq

Dusen 02-03-2005 06:50 AM

The hahah stuff is just '=true' with double equals.

Asher, I hit you up on your ICQ.

arnette 02-03-2005 06:54 AM

Hit me up 243680554

arnette 02-03-2005 07:12 AM

Quote:

Originally Posted by arnette
Hit me up 243680554

Still waiting...

rvincent 02-03-2005 07:38 AM

$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