Posted by otto on 11/29/07 20:32
Hello to all,
I have the following script. This one read pictures in a directory and show them quickly.
The $files array is about 4000 rec. big. When the variable $filtre should select only 10 to 50 pictures it take to much time for the moment and I'm looking if
I can optimize this.
Question : it is possible with PHP to analyses the used time between some scripts lines?
Could be more difficult when I'm also using Javascript!
Thanks in advance for any help.
Otto
// Session variables
$files = $_SESSION['files'];
$filtre = $_GET['filtre'];
# Display speed
$peed = 250;
# Directory of pictures
$pict_path = "camera25/";
echo "
<script type='text/javascript'>
Animation=new Array();
bild=new Array();
var i=0;
";
# Selection (filtre)
$by = 1;
while ($by < count($files))
{
if (substr($files[$by],10,6) == $filtre)
{
echo "bild[$by]='$pict_path$files[$by]';\n";
}
$by++;
}
echo "
for(r=0;r < $by; r++)
{
Animation[r]=new Image(); Animation[r].src=bild[r];
}
function anzeigen()
{
if(i < $by){
document.images.dummy.src=Animation[i].src;
i++;
}
else
{
i=0;
}
setTimeout('anzeigen()',$peed);
}
</script>
<body onLoad='anzeigen();'>
<div align=left><img name='dummy'></div>";
?>
[Back to original message]
|