On Fri, 2005-11-11 at 15:25, cybermalandro cybermalandro wrote:
> I have this that looks like this
> 
> array(3) {
>   [0]=>
>   array(2) {
>     [0]=>
>     string(1) "1"
>     [1]=>
>     string(1) "2"
>   }
>   [1]=>
>   array(2) {
>     [0]=>
>     string(3) "492"
>     [1]=>
>     string(3) "211"
>   }
>   [2]=>
>   array(2) {
>     [0]=>
>     string(2) "11"
>     [1]=>
>     string(2) "20"
>   }
> }
> 
> I want to loop through so I can get and print "1","492","11" and
> "2","211","20" What is the best way to do this? I suck with arrays and
> I can't get my looping right.

$a = array(array(1,2),
           array(492,211),
           array(11,20)
     );

for($i=0;$i<2;$i++) {
    foreach($a as $v) {
        echo $v[$i] . "\n";
    }

    echo "======\n";
}

Prints:

1
492
11
======
2
211
20
======


-Brian
-- 

s/:-[(/]/:-)/g


Brian        GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
======================================================================
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to