- <?php
-
$counter= array(); // This is a Empty Array
-
array_push($counter,"Some_value"); // You have to Assign values To Array LIke This
-
array_push($counter,"Another_value");
-
array_push($counter,"One_More_value");
-
?>
-
Hi.
That can also be accomplished like this: (my personal preference)
-
$counter = array();
-
$counter[] = "First";
-
$counter[] = "Second";
-
$counter[] = "Third";
-
And even like this:
-
$counter = array(
-
0 => "First",
-
1 => "Second",
-
2 => "Third"
-
);
-
These three methods all do the same thing, just a matter of preference which one you use.
The original problem, as I am sure you have gathered after ajaxrand's post, is that the array, $counter, has no elements. Thus, calling elements, no matter at what index, will not yield any results and should print a "Notice: Undefined index...".