Jump to content

need help debugging function...


The14thGOD

Recommended Posts

So I have a really complicated search/filter system going on here and am trying to get a couple items to work. For some reason they are not. The only thing I can see that is common between the two not working examples is the & character.

 

There are multiple practice areas (the [XX] is there for tying specialties to practice areas which has to be editable by client). Here I am just trying to get the practice area and not anything else. It should be pretty straight forward. I had it working before without the brackets so not sure why it's not working now. Should be pretty straight forward.

<?php
/*
Example print_r of $cats = Array ( [0] => [CL]Commercial Litigation [1] => [PL]Product Liability/Mass Tort [2] => [HC]Health Care Law & Consulting [3] => [LE]Labor & Employment [4] => [bG]Business Group )

Example $practice_areas = Commercial Litigation| Health Care Law & Consulting

Working $ps examples = [CL] || [PL] || [bG]
Not-working $ps examples = [HC] || [LE]
*/
function checkPracticeAreas2($practice_areas,$cats){
	$member = false;
	//$practice_areas = str_replace('&','&#038;',$practice_areas);
	$practice_areas = str_replace('[L]','',$practice_areas);//remove leader attr
	$practice_areas = explode('|',$practice_areas);

	//find which practice area
	$ps = $_GET['ps'];
	$plus = stripos($ps,'+');//if specialty is present, just get the practice_area intials 
	if($plus !== false){
		$xpld = explode('+',$ps);
		$ps = $xpld[0];
	}
	for($i=0;$i<sizeof($cats);$i++){
		$isAbbr = stripos($cats[$i],urldecode($ps));
		if($isAbbr !== false){
			$the_practice = substr($cats[$i],4);
			break;
		}
	}

	for($i=0;$i<sizeof($practice_areas);$i++){
		$isPracticeArea = stripos($practice_areas[$i],$the_practice);
		if($isPracticeArea !== false){
			$member = true;
			break;
		}
	}
	return $member;
}
?>

 

I don't know if I've started at this for too long or what I'm missing...but I'm just running in circles.

 

Thanks for any and all help,

Justin

Link to comment
Share on other sites

not sure I get what you're doing here...

 

if, as you say,  $practice_areas = "Commercial Litigation| Health Care Law & Consulting"

 

why are you doing this if there is no [L] in $practice_areas ?

 

$practice_areas = str_replace('[L]','',$practice_areas);

 

Link to comment
Share on other sites

Some people have [L] in front of the practice area because they are the group leader so it just runs automatically to make sure it's not in the string. The example I gave just happened to not have it. Sorry, should of removed it to avoid confusion.

 

Basically I'm calling the function:

 

$member = checkPracticeAreas2($practice_areas,$cats);

If it's returns true I do some other stuff to it.

For some reason whenever [HC] or [LE] is to be matched it always returns false. (It should return true 5-30 times depending on category).

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.