[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") !==
		$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
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" ;-)



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

Jonathan Schwartz
Exit 445 Group
jonathan at exit445.com
FX.php_List mailing list
FX.php_List at mail.iviking.org

More information about the FX.php_List mailing list