On 20 February 2010 11:18, <clancy_1@xxxxxxxxxxxx> wrote: > Or: > > $a = array ('Cats', 'white', 'Dogs', 'black', 'Mice', 'grey', 'Camels', 'brown'); > $b = ''; // Just in case it has some leftover value > $k = 2* (int) (count ($a)/2); // ensure even no of terms > $i = 0; while ($i < $k) > { > $b[$a[$i++]] = $a[$i++]; // *** > } > > And this works: > $i = 0; $k = array_keys($b); > while ($i < count($b)) { echo '<h5>'.$i.': '.$k[$i].' = '. $b[$k[$i++]].'</h5>'; } > > 0: Cats = white > 1: Dogs = black > 2: Mice = grey > 3: Camels = brown > > ( *** I have always been wary of using statements like this because I was unsure when the > incrementing would occur, so I tried it.) > > Clancy <?php $i = 10; echo $i++; // Shows 10 and $i becomes 11 echo ++$i; // $i becomes 12 and 12 is shown. ?> Post increment and pre increment. No need to be "wary" of them. http://docs.php.net/manual/en/language.operators.increment.php -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php