Archive - Jun 29, 2007

Loop multiple associative array at the same time

Today, someone in asked me a question in Qunu asked me a question to loop though 2 associative array at the same time.

Suppose, 2 associative arrays, $a and $b. They have some information corresponding to each other according to their position, but they are not numeric arrays, and it is not possible to manipulate one array's value or key to get another array's key.

My suggestion is to loop though 2 arrays with foreach separately, build them as 2 numeric array and then we will have a numeric key to access them.

foreach($a as $key=>$var){
$num_a[] = array($key=>$var);
}
foreach($b as $key=>$var){
$num_b[] = array($key=>$var);
}

Two foreach loops... if there is more arrays like this, there will be a lot more loops. If the key's information want to be preserved,

The qunu user told me a better code, use each().

foreach($a as $akey=>$avar){
$tmpb = each($b);
$bkey = $tmpb['key'];
$bvar = $tmpb['value'];
}

I didn't have time to ask who he was before he quits from the room.

Zong-Go mobile

in

Zong, part of Echovox, is a platform for mobile applications. There is a API so you can create services running on their platform.
how zong work.
Zong pays money if you get subscribers, and the easiest program possible is RSS parsing service. You supply the RSS URL and set the price and they will do everything else for you. Easy money baby

Honey Pot that kill bots