in reply to Count of element in array - Help

Hi,

This line:

$MMANS=$arr[($ANS-1)][3];
is populating the array with a new element $arr[($ANS-1)] if it doesn't exist. See autovivification.

I would suggest validating your input and disallowing a value greater than the number of elements in your array.

Hope this helps!


The way forward always starts with a minimal test.