view Phoenix's home page
Phoenixblogbookmarksrss feeds
ecastr . sign in . register

blog

It's time to continue with my attempts to find which is the better (most optimized) way to program in PHP. In previous post I took a look at string concatenating. This time I'm going to iterate over arrays. The main goal is to get the key and the value of each item in an array.

Let's start:

Iterate over arrays test:

This is the target array

$values = array("a", "b", "c", "d", "e", "f");

and these are my test cases

Case 1:
foreach($values as $k=>$v){
}


Case 2:
for($k = 0; $k < sizeof($values); $k++){
$v = $values[$k];
}



Case 3:
$count = ...
comments . published on 16 nov 07 to optimization, performance, php
Hi, this is the first post from the series I'm starting about how to optimize
your PHP code. I'll focus mainly on code comparisons so you can see which is the
fastest way to do something in PHP. You are welcome to comment on tests that
I'll do, suggest tests that are interesting to you and ask questions. I'm sure
you'll find a satisfying answers by me or the community.
The idea is to post a chapter every week, but I'm sure you'll get
one even early.
So let's start with today's tests:
Concatenating strings test:




This are some of the most popular ways to concatenate strings. So let's test
them and see which is the ...
comments . published on 11 nov 07 to optimization, performance, php
popular tags
recent posts
blog
© ecastr 2008 beta  about . blog . toolbar . terms of use . privacy . feedback