kevinkhan Posted January 31, 2011 Share Posted January 31, 2011 can anybody tell me how i can complete this function in php? // $page = html source file define("LIST_OF_SCHOOLS", "Piarsaigh,Phiarsaigh,Vincents"); $schoolList = explode(',', LIST_OF_SCHOOLS); function checkForSchool($page, $schoolList) { preg_match('|Goes to \\\u003ca href=\\\\"http:\\\/\\\/www.facebook.com\\\/pages\\\/[a-zA-Z-]*\\\/\d*\\\\" data-hovercard=\\\\"\\\/ajax\\\/hovercard\\\/page.php\?[a-zA-Z=0-9]*\\\\">([a-zA-Z\s]*)\\\u003c\\\/a>|', $page, $match); if($match && count($match)>0) { echo "Match Found"; // if any of the words in the schoolList array is found in the match from the preg_match function let the // checkForSchool function return true // other wise return false } } } Quote Link to comment https://forums.phpfreaks.com/topic/226291-how-do-i-complete-this-funtion-does-anybody-know/ Share on other sites More sharing options...
Maq Posted January 31, 2011 Share Posted January 31, 2011 Looks like you haven't even tried... You have the if (just add return TRUE;) then just add the else with a return of FALSE in it. Quote Link to comment https://forums.phpfreaks.com/topic/226291-how-do-i-complete-this-funtion-does-anybody-know/#findComment-1168098 Share on other sites More sharing options...
maxudaskin Posted January 31, 2011 Share Posted January 31, 2011 function checkForSchool($page, $schoolList) { preg_match('|Goes to \\\u003ca href=\\\\"http:\\\/\\\/www.facebook.com\\\/pages\\\/[a-zA-Z-]*\\\/\d*\\\\" data-hovercard=\\\\"\\\/ajax\\\/hovercard\\\/page.php\?[a-zA-Z=0-9]*\\\\">([a-zA-Z\s]*)\\\u003c\\\/a>|', $page, $match); if($match && count($match)>0) { echo "Match Found"; return true; } return false; } Quote Link to comment https://forums.phpfreaks.com/topic/226291-how-do-i-complete-this-funtion-does-anybody-know/#findComment-1168099 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.