You are here: Re: [PHP] arrays question « PHP « IT news, forums, messages
Re: [PHP] arrays question

Posted by Brian V Bonini on 11/12/05 16:04

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация