The14thGOD Posted August 11, 2011 Share Posted August 11, 2011 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('&','&',$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 Quote Link to comment https://forums.phpfreaks.com/topic/244555-need-help-debugging-function/ Share on other sites More sharing options...
WebStyles Posted August 12, 2011 Share Posted August 12, 2011 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); Quote Link to comment https://forums.phpfreaks.com/topic/244555-need-help-debugging-function/#findComment-1256164 Share on other sites More sharing options...
The14thGOD Posted August 12, 2011 Author Share Posted August 12, 2011 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). Quote Link to comment https://forums.phpfreaks.com/topic/244555-need-help-debugging-function/#findComment-1256172 Share on other sites More sharing options...
The14thGOD Posted August 12, 2011 Author Share Posted August 12, 2011 well after coming back i remembered why it's not going to work, wordpress sometimes stores & as & and other times &, just had to change it to the right one to match correctly. Quote Link to comment https://forums.phpfreaks.com/topic/244555-need-help-debugging-function/#findComment-1256202 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.