Code Executing Slowly

Hello

I have written some code that returns job search results based on some criteria:
Here is the link: http://career-updates.org/kath.php?page=6&what=sales&where=florida&x=60&y=17

I copy the job results into an array and then parse out using a pagination routine.

This code is executing so slow as you will see it running at the above link.

Thank you.

Use xDebug to profile your code:

http://xdebug.org/docs/profiler

You definitely have some inefficiencies. First of all, you are retrieving the job listing for page 1 to get the total number of pages, and then requesting page 1 again in your loop (just load page 1 based on your total number of pages logic, and skip page 1 in the loop).

Second, you are looping through all of the pages on each page load… Why? Just load the single page you need. You are effectively calling api.juju.com/jobs 11 times to load 10 results.

Instead, you should call api.juju.com/jobs 1 time, passing the page you want to load, use the totalresults node to build the navigation/paging, and loop through $rss->channel->item to load the results.