I have written a simple php script running within drupal. It imports json from a different server and converts it to a multidimensional array. when I added a for-loop which rewrites the array a bit, the loading time increased from 1 second to 5 seconds. Am I doing something wrong here?
part of original "fast" code:
public function give_nausys_request_rew_array() {
$this->jsonarray = drupal_json_decode($this->give_nausys_request());
$this->jsonarray = $this->jsonarray[reservations];
return $this->jsonarray;
}
part of "slow" code:
public function give_nausys_request_rew_array() {
$this->jsonarray = drupal_json_decode($this->give_nausys_request());
$this->jsonarray = $this->jsonarray[reservations];
$this->arraycount = count($this->jsonarray)-1;
for ($i = 0; $i <= $this->arraycount; $i++) {
$this->jsonarray[$i][GUID] = $this->jsonarray[$i][yachtId].'-'.$this->jsonarray[$i][periodFrom].'-'.$this->jsonarray[$i][periodTo];
}
return $this->jsonarray;
}