Hey I'm submitting a form in php and accessing inputs via 'name' attribute. When I print my array using print_r($array), it gives:
Array ( [0] => 1 [1] => 5 [2] => 9 [3] => 13 )
But when I access this array using $array[0] or $array['0'], It prints 'A' only. Then I tried encoding it to json_encode($array), the result was:
"Array
(
[0] => 1
[1] => 5
[2] => 9
[3] => 13
)
"
I'm fed up of this error. Kindly help buddies. Thanks in advance.
Editing:
This is code I'm using to fill an array from a dynamically created form:
for($j=0;$j<$i;$j++)
{
$name = $_POST['abc'.$j];
}
This php array is then passed to a radio button in a form, the code is:
echo "<input id='radio' name='$name' class='myclass' type='radio' value=".$row2['ProdId'].">" .$row2['ProdName'];
I'm just getting the values from a form and filling it in an array:
$name = $_POST['abc'];
Now on other page, I'm receiving these values as: $array = $_POST['name']; print_r($array);
it prints:
Array ( [0] => 1 [1] => 5 [2] => 9 [3] => 13 )
but when I access any element like 1,5,9,13 using $array[0], It prints 'A'
I tried json_encoding the array, but the situation gets worse