foreach - speed php load time up -


i have following php code:

// add unsubscribers array $unsubs = array(); foreach($unsubscribers->response->results $entry2) {     $unsubs[] = $entry2->emailaddress; }  // loop through subscribers foreach($result->response->results $entry) {       echo '<tr class="'. $entry->emailaddress.'">';           echo '<td>'. $entry->emailaddress.'</td>';     echo '<td></td><td>';      // if subscriber in our unsubscriber array, output email again     if(in_array($entry->emailaddress, $unsubs)) {          echo $entry->emailaddress;     }      echo '</td><td></td>';     echo '<td></td>';     echo '<td></td>';     echo '</tr>';  } 

where empty <td></td> located place following:

$getlists = new cs_rest_campaigns($_post['campaign_id'], $auth); $getlistsresult = $wrap->get_lists_and_segments();     foreach($getlistsresult->response->lists $list) {         //echo $list->listid;     }   $wrapcount = new cs_rest_subscribers($list->listid, $auth); $resultcount = $wrapcount->get_history($entry->emailaddress);          foreach($resultcount->response $entrycount) {           $counts = array();  foreach($entrycount->actions $actions) {     if(!isset($counts[$actions->event])) {         $counts[$actions->event] = 0;     }     ++$counts[$actions->event]; }       echo '<td>';     if ($counts['click']){echo $counts['click'];}      echo '</td>';      echo '<td>';     if ($counts['bounce']){echo 'yes';}     echo '</td>';      echo '<td>';     if ($counts['open']){echo $counts['open'];}      echo '</td>';      } 

this works degree, load time of page dramatically increased. think honest code need tidying up. suggestions on how speed up?

there's not can see blatantly unoptimized in code, there functions calls don't know about, cs_rest classes, don't know these functions or if can slow or optimized.

with information, thing can see might using splfixedarray class. notably useful if have lot of entries in arrays , lot of operations on them. basically, similar real arrays, in way index integer , have fixed size, in turn makes them faster use.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -