Jump to content

Arrays


MemphiS

Recommended Posts

To add a new value to an array, use something like this:

 

<?php

$array = array("value1");

/* Array currently looks like this: *\

Array
(
     [0] => value1
)

\*                                   */

$array[] = "value2"; // "value2" is added as the next value onto the array

/* Array now looks like this: *\

Array
(
     [0] => value1
     [1] => value2
)

\*                             */

// And so on...

?>

 

[] can be added on the end of an array to add a new value to the end, basically.

Link to comment
https://forums.phpfreaks.com/topic/53720-arrays/#findComment-265468
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.