0

$data = array();

$x = count($data)+1;
echo $x;
$data[$x] = $_GET['nama'];

for($i=0;$i<=count($data);$i++){
echo $data[$i];
}

?>

i had thinked, but not yet have solved

kito
  • 3
  • 1

2 Answers2

0

Dear Kito Why don't you use array_push function to push the element at the end of the array. Just like this:

array_push($data, $_GET['nama']);

or you can simply use:

$data[] = $_GET['nama'];
  • oh sorry, i don't now thanks, that is very helpful but, only ask, is there any way to use the index method – kito Oct 25 '14 at 17:44
  • Your welcome. If you need to put an element between other elements and in a certain index of the array please check the following link: [How to insert element into array to specific position?](http://stackoverflow.com/questions/3353745/how-to-insert-element-into-array-to-specific-position) – Hamed Forsi Oct 25 '14 at 17:50
0
$data = array();
$x = count($data)+1;
echo $x;
$data[$x] = "test";

for($i=1;$i<=count($data);$i++){
    echo $data[$i];
}
Hemant
  • 181
  • 3
  • 14