I am receiving an error which I understand by meaning but do not know the solution to fix, the error I am receiving states:
Fatal error: Cannot redeclare ExpandOptionType() (previously declared
in …:269) in … on line 269
Below is code:
foreach ($arrQuestionId as $key=>$question) {
?>
<div class='lt-container'>
<p><?php echo htmlspecialchars($arrQuestionNo[$key]) . ": " . htmlspecialchars($arrQuestionContent[$key]); ?></p>
<?php
function ExpandOptionType($option) { //LINE 269
$options = explode('-', $option);
if(count($options) > 1) {
$start = array_shift($options);
$end = array_shift($options);
do {
$options[] = $start;
}while(++$start <= $end);
}
else{
$options = explode(' or ', $option);
}
return implode(" ", $options);
}
?>
<p><?php echo ExpandOptionType(htmlspecialchars($arrOptionType[$key])); ?></p>
</div>
<?php
}
?>
Move your function outside of your foreach loop…