this might a stupid question, and I must admit I dont know how PHP works exactly when assigning data to a variable, either a string, an int or an array.
assume this :
foreach ($redirs['0'] as $key => $value) {
$tmp['years'] = trim($redirs['1'][$key]);
$tmp['expiration'] = trim($redirs['2'][$key]);
$tmp['source'] = trim($redirs['3'][$key]);
$tmp['destination'] = trim($redirs['4'][$key]);
array_push($redirections, $tmp);
}
In this example, im building an array of redirections that our users have set. The $redirs array is coming from a preg_match_all on a plain text file.
Anywho, my question is, would I make PHP use memory more wiselly if I resetted the $tmp array in the foreach loop, like this :
foreach ($redirs['0'] as $key => $value) {
$tmp['years'] = trim($redirs['1'][$key]);
$tmp['expiration'] = trim($redirs['2'][$key]);
$tmp['source'] = trim($redirs['3'][$key]);
$tmp['destination'] = trim($redirs['4'][$key]);
array_push($redirections, $tmp);
unset($tmp);
}
Would that make the script run more rapidelly ? Or does PHP auto-magically frees memory used by the last use of $tmp when im assigning new data to it ?
Thanks for any pointers on this one =)