...

View Full Version : Better / faster code



Haros
11-23-2008, 10:08 AM
For a faster and less "memory eating" php code...
...is it faster to have 3 foreach commands in a row or better to have one foreach command and then separately have 3 others which are pointing to the value I want in xml?

For example (because I think you didn't understand anything from the way I described my problem :p )

I am trying to parse some xml values into normal php variables. the way I do it is

for($i=0; $i<sizeof($xml->weeklytrackchart->track); $i++){
foreach($xml -> weeklytrackchart -> track[$i] -> artist as $artist[$i]);
foreach($xml -> weeklytrackchart -> track[$i] -> name as $name[$i]);
foreach($xml -> weeklytrackchart -> track[$i] -> playcount as $playcount[$i]);

would it be better to have in a loop one foreach like

foreach($xml -> weeklytrackchart -> track[$i] as $path);

and then do something like

$path->artist[$i];

$path->name[$i];

$path->playcount[$i];

or there is a more efficient way?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum