Jump to content

Quick array question...


Chappers

Recommended Posts

Hi,

 

I know you can make an array containing multiple values, and print them, like this:

$folder = array("hello", "world");
foreach ($folder as $contents) {
echo "$contents<br>";
}

and I know you can make an array in which you can keep adding single values, like this:

$folder[] = "hello";
$folder[] = "world";
foreach ($folder as $contents) {
echo "$contents<br>";
}

but how do you make an array that you can keep adding multiple values to? This doesn't work, as it outputs the array() as "Array" followed by "and goodbye":

$folder[] = array("hello", "world");
$folder[] = "and goodbye";
foreach ($folder as $contents) {
echo "$contents<br>";
}

and you can't add more than one value using the format $folder[] = "whatever", "whatever"); as it brings up a server error.

 

Is there a simple answer? Thanks a lot!

Link to comment
https://forums.phpfreaks.com/topic/131975-quick-array-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.