I'm trying to create a page that will dynamically create input buttons if the string contains an "a" and otherwise increment the value and display the string.
Here is my function that checks it, it works but every input has the same name, and $num
does not get updated.
Any help would be much appreciated, thanks in advance.
$num = 0;
function isAnswer($a, $i) {
if (strpos($a, 'a') !== false) {
return '<input type="radio" name="gender'.$num.'" value="male">';
} else {
++$num;
return $a .":";
}
}