snolan760 Posted June 24, 2010 Share Posted June 24, 2010 I’m trying to get one “id/number” from an array, below is my code. $Groups = array("Groups"); $groups = $myApp->loadCon($cid, $Groups); while(list($key, $value) = each($groups)) { echo "<font id=\"key\"><u>List of Tags</u></font> <br> <font id=\"value\">$value</font> <br><br>"; } With the image attached, I want to be able to grab the “940” id and send a user to another page depending if they have that “id” or not. I know how to redirect someone, but I can’t seem to get just the one “id” from an array. Would I need to use preg_match??? Thx, SJ [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/205800-preg_match-expects-parameter-2-to-be-string-array-given-in/ Share on other sites More sharing options...
JasonLewis Posted June 25, 2010 Share Posted June 25, 2010 Couldn't you just loop through the groups array? foreach(explode(",", $array['groups']) as $g){ if($g == '940'){ // has id 940 } } Or, if you wanted to use preg_match(): if(preg_match("#(940)#", $array['groups'])){ // has id 940 } Hope that helps. Link to comment https://forums.phpfreaks.com/topic/205800-preg_match-expects-parameter-2-to-be-string-array-given-in/#findComment-1077011 Share on other sites More sharing options...
snolan760 Posted June 25, 2010 Author Share Posted June 25, 2010 I actually went with strpos() and it worked, but I will try this as well thanks SJ Link to comment https://forums.phpfreaks.com/topic/205800-preg_match-expects-parameter-2-to-be-string-array-given-in/#findComment-1077024 Share on other sites More sharing options...
JasonLewis Posted June 25, 2010 Share Posted June 25, 2010 Yeah anything like that would work fine. Link to comment https://forums.phpfreaks.com/topic/205800-preg_match-expects-parameter-2-to-be-string-array-given-in/#findComment-1077026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.