[FX.php List] PHP question

VanBuskirk, Patricia pvanbuskirk at otc.fsu.edu
Thu Jan 14 08:26:04 MST 2010


Ok, I tried both:

if (isset($_POST['Department_Name']) && ($_POST['Department_Name'] ==
"Student Request" || strpos($_POST['Department_Name'],"Hall") !==
FALSE)) {
		$Student_Dept_Request_Flag = "Student";
		} else {
		$Student_Dept_Request_Flag = "Department";
		}

if (isset($_POST['Department_Name']) && ($_POST['Department_Name'] ==
"Student Request" || preg_match('/ Hall$/', $_POST['Department_Name'])
)) {
		$Student_Dept_Request_Flag = "Student";
		} else {
		$Student_Dept_Request_Flag = "Department";
		}

It doesn't error out, but I checked "Department" in the
Student_Dept_Request_Flag field and clicked on a ".. Hall" in the
Department dropdown and it does not change "Department" to "Student".
The other part of the equation does change it, however ... if I choose
"Student Request" from the dropdown.



-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Jonathan
Schwartz
Sent: Thursday, January 14, 2010 9:54 AM
To: FX.php Discussion List
Subject: Re: [FX.php List] PHP question

How about this...

A strpos($haystack,$needle) would also work. The function is designed 
to return the position of the "needle" in the "haystack", but also 
returns "FALSE" if the needle does not exist.

I understand that it is faster than PREG.

if(strpos($_POST['Department_Name'],"Hall") !== FALSE)
  {
Do this
}

To avoid problems resulting from upper/lower case, use stripos().

Hope there is no "Monte Hall Hall" ;-)

HTH

Jonathan

>A preg_match will work.
>
>if (isset($_POST['Department_Name']) && preg_match('/hall$/i', 
>$_POST['Department_Name']) {
>--
>GARETH EVANS
>


-- 
Jonathan Schwartz
Exit 445 Group
jonathan at exit445.com
http://www.exit445.com
415-370-5011
_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list


More information about the FX.php_List mailing list