I am just doing some experimenting. How do I print the value of this $chvalues[] or test (as below) it’s an array. Is it possible to print this out as-is? $chvalues[] (yes my input field is properly defined with name=seminar etc…)
$chvalues = array();
if (isset($_POST['seminar'])) {
foreach ($_POST['seminar'] as $ch => $value) {
$chvalues[] = $value;
if(is_array('$chvalues[]')) {
echo "Yes. It's an Array.";
}
}
}
I am trying to test this:
if(is_array('$chvalues[]')) { ...
I get this:
Fatal error: Cannot use [] for reading in...
You are reading the array as a string by using single quotes around it (which should just return false).
You should use
if(is_array($chvalues))without the brackets.$chvalueswill always be an array, because you just assigned it to one the line before, as well as at the start of your code, before the loop.Maybe you meant to check
$value, or run theis_array()after the loop and not initialize$chvaluesas an array before running the loop.