2

This little snippet will teach you all about arrays and arrays of arrays, and so on and so forth.

Votes + Comments
Thanks for sharing!
<?php
$foo = array('1' => 'Hello, World!'
                  '2' => 'PHP is the best!'
                  'var' => '');
$foo['var'] = array('1' => 'foo', '2' => 'bar');
//Simple, no? Now...how do we call them?

echo $foo['1'];
// Output: Hello, World!

$i = '2';
echo $foo[$i];
// Output: PHP is the best!

echo $foo['var']['1'] . $foo['var']['2'];
// Ouput: foobar

// I hope this cleared up a lot about arrays for
// you, and how useful they can be, especially
// with a for(); or while(); statement!
?>
2
Contributors
1
Reply
26
Views
12 Years
Discussion Span
Last Post by LastMitch
0

This little snippet will teach you all about arrays and arrays of arrays, and so on and so forth.

Thanks for sharing! I like it. I attached an image of how it looks.

d08405329f7206deb33e08451de2ca28

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.