Most efficient way to compare/match two large arrays?

Jadenyne

New Member
I am writing a very process-intensive function in PHP that needs to be as optimized as it can get for speed, as it can take up to 60 seconds to complete in extreme cases. This is my situation:I am trying to match an array of people to an XML list of jobs. The array of people have keywords that I have already analyzed, delimited by spaces. The jobs are from a large XML file.It's currently setup like this: \[code\]$matches = new array();foreach($people as $person){ foreach($jobs as $job){ foreach($person['keywords'] as $keyword){ $count = substr_count($job->title, $keyword); if($count > 0) $matches[$job->title] = $count; } }}\[/code\]I do the keywords loop a few times with different categories. It does what I need it to do, but it feels very sloppy and the process can take a very, very long time depending on the number of people/jobs.Is there a more efficient, or faster, way of doing this?
 
Back
Top