[OT] PHP speed question

Marielle Lange mlange at widged.com
Tue Oct 31 09:42:48 CST 2006


> I'm not trying to change this list into a PHP forum, but I have a
> question regarding speed optimization in PHP, especially about data  
> accumulation
> into strings... I need to accumulate a large number of pixel values  
> into a string before

Excuses excuses... that's just because you know that here you will  
get a rapid answer ;-). We should avoid this, however.

First thing, try by changing to one of these:

(1) "$myValue1 $myValue1 $myValue1\t" ;
(2) $myValue1 . ' ' . $myValue1 . ' ' . $myValue1 . "\t" ;     
(and     $s0 = '';)

(2) should a priori be the fasted (except that \t has to be in  
quotes). Content in "" is interpreted (if you put a variable , then  
it is replaced by its value). Content in '' is not.

Otherwise, if you want to explore arrays:
array_push --  Push one or more elements onto the end of array
<http://uk.php.net/function.array-push>
implode -- Join array elements with a string
<http://uk.php.net/manual/en/function.implode.php>

For the rest:
PHP Optimization Tricks
<http://ilia.ws/archives/12-PHP-Optimization-Tricks.html>

>  $s0 = "" ;
>  $s = "" ;
>
>  for($y = 0; $y < $h; $y++) {
>
>     $s0 = '' ;
>
>     for($x = 0; $x < $w; $x++) {
>
>         $s0 .= $myValue1 . " " . $myValue1 . " " . $myValue1 . "\t" ;
>
>     }
>
>   $s .= $s0 . "\n" ;
>  }
>
>
> Thanks,
> JB
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

------------------------------------------------
Marielle Lange (PhD),  http://widged.com
Bite-size Applications for Education








More information about the use-livecode mailing list