Modifing associative array keys & values (yes keys too). array_walk or foreach or something else?

There exists a big performance gap between the foreach and the array_map method. The fastest is the foreach construct. This construct can be five to six times as fast as an anonymous function, at least when there is not much to do within the loop.In most scenarios, the time it takes to iterate over the array is negligible compared to the time spend in the loop or anonymous function.

So this performance difference does not really matter For more information see link here.

There exists a big performance gap between the foreach and the array_map method. The fastest is the foreach construct. This construct can be five to six times as fast as an anonymous function, at least when there is not much to do within the loop.In most scenarios, the time it takes to iterate over the array is negligible compared to the time spend in the loop or anonymous function.

So this performance difference does not really matter. For more information see link here.

$result = array(); foreach ($array as $key => $value) $result":$key" = "{$value}xx.

One quick way is to make a new array with the new keys and values, using a foreach loop, then replace your old array with the new one. $old = array( 'key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3' ); $new = array(); foreach ($old as $k => $v) { $new":$k" = $v . "xx"; } $old = $new.

– Billy Moon Jun 6 '11 at 10:06 @Billy Moon: Oops, not dirty at all, guess I was just typing too quickly and that phrase just popped up subconsciously. – BoltClock? Jun 6 '11 at 10:08.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions