Php Experts,
I got this array:
Step 1
[code]
//$radio_button_gender_options = array(‘Male’,’Female’,’Male To Female’,’Female To Male’);
$radio_button_gender_options[]=’Male’;
$radio_button_gender_options[]=’Female’;
$radio_button_tos_options = array(‘Yes’,’No’);
Step 2
And I did this:
[code]
$value = $form_question_label;
$value_1 = str_replace(“”,”_”,”$value”); //Replaced Spaces to Underscores.
$value_2 = strtolower(“$value_1”); //Replaced Upper Case to Lower Case.
//$radio_button_gender_options = array(‘Male’,’Female’,’Male To Female’,’Female To Male’);
$current_radio_button_options = “$” . “radio_button_” . “$value_2” . “_options”;
$current_radio_button_option = “$” . “radio_button_” . “$value_2” . “_option”;
Step 3
Therefore, this should work as the Array Name is correct:
[code]
foreach($current_radio_button_options as $current_radio_button_option) //Loop through the whole appropriate ‘Radio Buttons’ array.
{
echo “<input type=”radio” id=”$current_radio_button_option” name=”$value_2″ value=”$current_radio_button_option”>
<label_for=”$radio_button_gender_option”>$form_question_label</label><br>”;
}
But I get error:
**Warning: Invalid argument supplied for foreach() in C:xampphtdocstestsearch_2.php on line 130
Line 130 is this:
[code]
foreach($current_radio_button_options as $current_radio_button_option) //Loop through the whole appropriate ‘Radio Buttons’ array.
It seems php does not recognise this variable as array:
[code]
$current_radio_button_options
It should. Look at step 2 above.
The original Array is actually this:
[code]
//$radio_button_gender_options = array(‘Male’,’Female’,’Male To Female’,’Female To Male’);
$radio_button_gender_options[]=’Male’;
$radio_button_gender_options[]=’Female’;
$radio_button_gender_options[]=’Male To Female’;
$radio_button_gender_options[]=’Female To Male’;
$radio_button_tos_options = array(‘Yes’,’No’);
But remember at step 2, I did this:
[code]
//$radio_button_gender_options = array(‘Male’,’Female’,’Male To Female’,’Female To Male’);
$current_radio_button_options = “$” . “radio_button_” . “$value_2” . “_options”;
$current_radio_button_option = “$” . “radio_button_” . “$value_2” . “_option”;
So it is like say, the array is called “tom”.
But instead of looping (foreach) through Tom, I am doing it like this:
bert = tom
Now loop foreach thru ‘bert’.
Now, doesn’t foreach loop work that way ? Do you have to give the original Array Name or what ?
Why am I doing it like this ? There is a reason for it. Not pasting here the full code as it is too long. If you look at the full code then you will see I have to do it like this.
<i>
</i>foreach($current_radio_button_options as $current_radio_button_option) //Loop through the whole appropriate 'Radio Buttons' array.
{
echo "<input type="radio" id="$current_radio_button_option" name="$value_2" value="$current_radio_button_option">
<label_for="$current_radio_button_option">$current_radio_button_option</label><br>";
}
<i>
</i>foreach($current_radio_button_options as $current_radio_button_option) //Loop through the whole appropriate 'Radio Buttons' array.
<i>
</i>$current_radio_button_options
<i>
</i>$current_radio_button_option
foreach()
$current_radio_button_options
<i>
</i>foreach(array $current_radio_button_options as $current_radio_button_option) //Loop through the whole appropriate 'Radio Buttons' array.
{
echo "<input type="radio" id="$current_radio_button_option" name="$value_2" value="$current_radio_button_option">
<label_for="$current_radio_button_option">$current_radio_button_option</label><br>";
}
<i>
</i>foreach($current_radio_button_options[] as $current_radio_button_option) //Loop through the whole appropriate 'Radio Buttons' array.
{
<i>
</i>$current_radio_button_options = "$" . "radio_button_" . "$value_2" . "_options";
$current_radio_button_option = "$" . "radio_button_" . "$value_2" . "_option";
>@developer_web#1617973 Or should I be fixing this instead:
> $current_radio_button_options = "$" . "radio_button_" . "$value_2" . "_options";
> $current_radio_button_option = "$" . "radio_button_" . "$value_2" . "_option";
<i>
</i>$current_radio_button_options = ${"radio_button_" . "$value_2" . "_options"};
<i>
</i><label for="first_name">First Name</label>
<input type="text" placeholder="Type your First Name here ..." name="first_name" required [A-Za-z0-9] autocorrect=off>
<i>
</i>$form_labels = array('First Name', 'Surname')
$form_item_names = array('first_name', 'surname')
<i>
</i>$form_labels = array('First Name', 'Surname')
<i>
</i><?php
//'USER' Form.
$form_questions_labels = array('First Name','Middle Name','Surname','Gender','Age Range','Education','Personal Email','About Me','Home Country');
$form_questions_required_labels = array('First Name','Surname','Gender','Age Range','Personal Email','About Me','Home Country');
//TEXT BOX LABELS.
$form_questions_textboxes_labels = array('First Name','Middle Name','Surname','Education','Personal Email');
//TEXT AREA LABELS.
$form_questions_textareas_labels = array('About Me');
//RADIO BUTTON LABELS.
$form_questions_radio_buttons_labels = array('Gender');
//DROPDOWN LABELS.
$form_questions_dropdowns_labels = array('Age Range','Home Country');
//RADIO BUTTONS AND THEIR OPTIONS
//'Gender' Options
$form_radio_button_number_[0] = array('Male','Female');
//DROPDOWNS AND THEIR OPTIONS
//'Age Range' Options
$form_dropdown_number_[0] = array('Select here','Under 16','16-20','21-25','26-30','31-35','36-40','41-45','46-50','51-55','56-60','61-65','66-70','71-75','76-80','81-85','86-90','91-95','96-100','100+');
//'Home Country' Options
$form_dropdown_number_[1] = array('Select here','Australia','Canada','New Zealand','USA','UK');
//Creates the New/Edit Record Webform.
//Since this webform is used multiple times in this file, best to make a function that is easily reusable to call the webform.
function renderForm($first_name = '', $middle_name = '', $surname = '', $gender = '', $age_range = '', $education = '', $marital_status = '', $working_status = '', $profession = '', $work_title = '', $personal_email = '', $about_me = '', $home_area = '', $home_town = '', $home_neighbourhood = '', $home_council = '', $home_borough = '', $home_city = '', $home_county = '', $home_district = '', $home_region = '', $home_state = '', $home_country = '', $error = '', $id = '')
{
//'USER' Form.
$form_questions_labels = array('First Name','Middle Name','Surname','Gender','Age Range','Education','Personal Email','About Me','Home Country');
$form_questions_required_labels = array('First Name','Surname','Gender','Age Range','Personal Email','About Me','Home Country');
<i> </i>//TEXT BOX LABELS.
<i> </i>$form_questions_textboxes_labels = array('First Name','Middle Name','Surname','Education','Personal Email');
<i> </i>
<i> </i>//TEXT AREA LABELS.
<i> </i>$form_questions_textareas_labels = array('About Me');
<i> </i>
<i> </i>//RADIO BUTTON LABELS.
<i> </i>$form_questions_radio_buttons_labels = array('Gender');
<i> </i>
<i> </i>//DROPDOWN LABELS.
<i> </i>$form_questions_dropdowns_labels = array('Age Range','Home Country');
<i> </i>//RADIO BUTTONES AND THEIR OPTIONS
<i> </i>//'Gender' Options
<i> </i>$form_radio_button_number_[0] = array('Male','Female');
<i> </i>//DROPDOWNS AND THEIR OPTIONS
<i> </i>//'Age Range' Options
<i> </i>$form_dropdown_number_[0] = array('Select here','Under 16','16-20','21-25','26-30','31-35','36-40','41-45','46-50','51-55','56-60','61-65','66-70','71-75','76-80','81-85','86-90','91-95','96-100','100+');
<i> </i>//'Home Country' Options
<i> </i>$form_dropdown_number_[1] = array('Select here','Australia','Canada','New Zealand','USA','UK');
<i> </i>?>
<i> </i><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<i> </i><html>
<i> </i><head>
<i> </i><title>Form</title>
<i> </i></head>
<i> </i><body>
<i> </i>
<i> </i><div class="container">
<i> </i><form action="" method="post">
<i> </i>
<i> </i><?php
<i> </i>foreach($form_questions_labels as $value)
<i> </i>{
<i> </i> $required_current_count_match = 'False';
<i> </i> $textbox_current_count_match = 'False';
<i> </i> $textarea_current_count_match = 'False';
<i> </i> $radio_button_current_count_match = 'False';
<i> </i> $dropdown_current_count_match = 'False';
<i> </i>
<i> </i> $current_value_matched = 'False';
<i> </i>
<i> </i> //Check if current Question is a * REQUIRED Question or not.
<i> </i> //There are 7 required questions: $form_questions_required_labels = array().
<i> </i> $required_current_count='0'; $required_count_end = '7'; $required_current_count_match = 'False';
<i> </i> while($value != $form_questions_required_labels[$required_current_count]||$required_current_count != $required_count_end)
<i> </i> {
<i> </i> if($value == "$form_questions_required_labels[$required_current_count]")
<i> </i> {
<i> </i> $current_required_label_number = $required_current_count;
<i> </i> $required_current_count_match = 'True';
<i> </i> $required_current_count = $required_count_end;
<i> </i>
<i> </i> $current_value_matched = 'TRUE';
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $required_current_count++;
<i> </i> }
<i> </i> }
<i> </i> if($current_value_matched != 'TRUE')
<i> </i> {
<i> </i> //Check if current Question's input type is a TextBox or not.
<i> </i> //There are 5 TextBox questions: $form_questions_textboxes_labels = array().
<i> </i> $textbox_current_count='0'; $textbox_count_end = '5'; $textbox_current_count_match = 'False';
<i> </i> while($textbox_current_count != $textbox_count_end)
<i> </i> {
<i> </i> if($value == "$form_questions_textboxes_labels[$textbox_current_count]")
<i> </i> {
<i> </i> $current_textbox_label_number = $textbox_current_count;
<i> </i> $textbox_current_count_match = 'True';
<i> </i> $textbox_current_count = $textbox_count_end;
<i> </i>
<i> </i> $current_value_matched = 'TRUE';
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $textbox_current_count++;
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i> if($current_value_matched != 'TRUE')
<i> </i> {
<i> </i> //Check if current Question's input type is a TextArea or not.
<i> </i> //There is 1 TextArea question: $form_questions_textareas_labels = array().
<i> </i> $textarea_current_count='0'; $textarea_count_end = '1'; $textarea_current_count_match = 'False';
<i> </i> while($textarea_current_count != $textarea_count_end)
<i> </i> {
<i> </i> if($value == "$form_questions_textareas_labels[$textarea_current_count]")
<i> </i> {
<i> </i> $current_textarea_label_number = $textarea_current_count;
<i> </i> $textarea_current_count_match = 'True';
<i> </i> $textarea_current_count = $textarea_count_end;
<i> </i>
<i> </i> $current_value_matched = 'TRUE';
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $textarea_current_count++;
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i> if($current_value_matched != 'TRUE')
<i> </i> {
<i> </i> //Check if current Question's input type is a RadioButton or not.
<i> </i> //There are 3 RadioButton questions: $form_questions_radio_buttons_labels = array().
<i> </i> $radio_button_current_count='0'; $radio_button_count_end = '1'; $radio_button_current_count_match = 'False';
<i> </i> while($radio_button_current_count != $radio_button_count_end)
<i> </i> {
<i> </i> if($value == "$form_questions_radio_buttons_labels[$radio_button_current_count]")
<i> </i> {
<i> </i> $current_radio_button_number = $radio_button_current_count;
<i> </i> $radio_button_current_count_match = 'True';
<i> </i> $radio_button_current_count = $radio_button_count_end;
<i> </i>
<i> </i> $current_value_matched = 'TRUE';
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $radio_button_current_count++;
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i> if($current_value_matched != 'TRUE')
<i> </i> {
<i> </i> //Check if current Question's input type is a DropDown or not.
<i> </i> //There are 3 DropDown questions: $form_questions_dropdowns_labels = array().
<i> </i> $dropdown_current_count='0'; $dropdown_count_end = '2'; $dropdown_current_count_match = 'False';
<i> </i> while($dropdown_current_count != $dropdown_count_end)
<i> </i> {
<i> </i> if($value == "$form_questions_dropdowns_labels[$dropdown_current_count]")
<i> </i> {
<i> </i> $current_drop_down_number = $dropdown_current_count;
<i> </i> $dropdown_current_count_match = 'True';
<i> </i> $dropdown_current_count = $dropdown_count_end;
<i> </i>
<i> </i> $current_value_matched = 'TRUE';
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $dropdown_current_count++;
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i>
<i> </i> //If current Question's input type is NOT a REQUIRED one and is a TextBox.
<i> </i> if($required_current_count_match == 'False' && $textbox_current_count_match == 'True')
<i> </i> {
<i> </i> //Need to replace 'Spaces' with '_'. And need to replace Upper Cases with Lower Cases as the 'name=" attributes are in lower cases with Under Scores instead of Spaces. Eg. Form Question Label 'Marital Status" is in form input field attribute "name='marital_status' or "id"='marital_status'".
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower($value_1); //Replaced Upper Cases to Lower Cases.
<i> </i> ?>
<i> </i> <div class="row">
<i> </i> <div class="col-25">
<i> </i> <label for="<?php echo $value_2;?>"><b><?php echo $value;?>: </b></label>
<i> </i> </div>
<i> </i> <div class="col-75">
<i> </i> <input type="text" name="<?php echo $value_2;?>" value="<?php echo ${$value_2}; ?>"/>
<i> </i> </div>
<i> </i> </div>
<i> </i> <?php
<i> </i> }
<i> </i> //If current Question's input type is NOT a REQUIRED one and is a TextArea.
<i> </i> elseif($required_current_count_match == 'False' && $textarea_current_count_match == 'True')
<i> </i> {
<i> </i> //Need to replace 'Spaces' with '_'. And need to replace Upper Cases with Lower Cases as the 'name=" attributes are in lower cases with Under Scores instead of Spaces. Eg. Form Question Label 'Marital Status" is in form input field attribute "name='marital_status' or "id"='marital_status'".
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower($value_1); //Replaced Upper Cases to Lower Cases.
<i> </i> ?>
<i> </i> <div class="row">
<i> </i> <div class="col-25">
<i> </i> <label for="<?php echo $value_2;?>"><b><?php echo $value;?>: </b></label>
<i> </i> </div>
<i> </i> <div class="col-75">
<i> </i> <textarea name="<?php echo $value_2;?>" rows="10" cols="30">
<i> </i> <?php
<i> </i> echo "Write about yourself here.";
<i> </i> ?>
<i> </i> </textarea>
<i> </i> </div>
<i> </i> </div>
<i> </i> <?php
<i> </i> }
<i> </i> //If current Question's input type is NOT a REQUIRED one and is a RadioButton.
<i> </i> elseif($required_current_count_match == 'False' && $radio_button_current_count_match == 'True')
<i> </i> {
<i> </i> //Need to replace 'Spaces' with '_'. And need to replace Upper Cases with Lower Cases as the 'name=" attributes are in lower cases with Under Scores instead of Spaces. Eg. Form Question Label 'Marital Status" is in form input field attribute "name='marital_status' or "id"='marital_status'".
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower($value_1); //Replaced Upper Cases to Lower Cases.
<i> </i> ?>
<i> </i> <div class="row">
<i> </i> <div class="col-25">
<i> </i> <label for="<?php echo $value_2;?>"><b><?php echo $value;?>: </b></label>
<i> </i> </div>
<i> </i> <div class="col-75">
<i> </i> <?php
<i> </i> foreach($form_radio_button_number_[$current_radio_button_number] as $value_3)
<i> </i> {
<i> </i> if($id != '' && $value_3 == ${$value_2})
<i> </i> {
<i> </i> //Even <?php echo "$value_3" is fine as both "$value_3" and "${$value_2}" hold same value. ${$value_2} is from database."
<i> </i> ?>
<i> </i> <input type="radio" name="<?php echo $value_2;?>" value="<?php echo ${$value_2};?>" checked><?php echo ${$value_2};?>
<i> </i> <?php
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> ?>
<i> </i> <input type="radio" name="<?php echo $value_2;?>" value="<?php echo $value_3;?>"><?php echo $value_3;?>
<i> </i> <?php
<i> </i> }
<i> </i> }
<i> </i> ?>
<i> </i> </div>
<i> </i> </div>
<i> </i> <?php
<i> </i> }
<i> </i> //If current Question's input type is NOT a REQUIRED one and is a DropDown.
<i> </i> elseif($required_current_count_match == 'False' && $dropdown_current_count_match == 'True')
<i> </i> {
<i> </i> //Need to replace 'Spaces' with '_'. And need to replace Upper Cases with Lower Cases as the 'name=" attributes are in lower cases with Under Scores instead of Spaces. Eg. Form Question Label 'Marital Status" is in form input field attribute "name='marital_status' or "id"='marital_status'".
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower($value_1); //Replaced Upper Cases to Lower Cases.
<i> </i> ?>
<i> </i> <div class="row">
<i> </i> <div class="col-25">
<i> </i> <label for="<?php echo $value_2;?>"><b><?php echo $value;?>: </b></label>
<i> </i> </div>
<i> </i> <div class="col-75">
<i> </i> <select id="<?php echo $value_2;?>" name="<?php echo $value_2;?>">
<i> </i> <?php
<i> </i> foreach($form_dropdown_number_[$current_drop_down_number] as $value_3)
<i> </i> {
<i> </i> if($id != '' && $value_3 == ${$value_2})
<i> </i> {
<i> </i> //Even <?php echo "$value_3" is fine as both "$value_3" and "${$value_2}" hold same value. ${$value_2} is from database."
<i> </i> ?>
<i> </i> <option value="<?php echo ${$value_2};?>" selected><?php echo ${$value_2};?></option>
<i> </i> <?php
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> ?>
<i> </i> <option value="<?php echo $value_3;?>"><?php echo $value_3;?></option>
<i> </i> <?php
<i> </i> }
<i> </i> }
<i> </i> ?>
<i> </i> </select>
<i> </i> </div>
<i> </i> </div>
<i> </i> <?php
<i> </i> }
<i> </i> //If current Question's input type is a REQUIRED one and is a TextBox.
<i> </i> if($required_current_count_match == 'True' && $textbox_current_count_match == 'True')
<i> </i> {
<i> </i> //Need to replace 'Spaces' with '_'. And need to replace Upper Cases with Lower Cases as the 'name=" attributes are in lower cases with Under Scores instead of Spaces. Eg. Form Question Label 'Marital Status" is in form input field attribute "name='marital_status' or "id"='marital_status'".
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower($value_1); //Replaced Upper Cases to Lower Cases.
<i> </i> ?>
<i> </i> <div class="row">
<i> </i> <div class="col-25">
<i> </i> <label for="<?php echo $value_2;?>"><b><?php echo $value;?>: *</b></label>
<i> </i> </div>
<i> </i> <div class="col-75">
<i> </i> <input type="text" name="<?php echo $value_2;?>" value="<?php echo ${$value_2}; ?>"/>
<i> </i> </div>
<i> </i> </div>
<i> </i> <?php
<i> </i> }
<i> </i> //If current Question's input type is a REQUIRED one and is a TextArea.
<i> </i> elseif($required_current_count_match == 'True' && $textarea_current_count_match == 'True')
<i> </i> {
<i> </i> //Need to replace 'Spaces' with '_'. And need to replace Upper Cases with Lower Cases as the 'name=" attributes are in lower cases with Under Scores instead of Spaces. Eg. Form Question Label 'Marital Status" is in form input field attribute "name='marital_status' or "id"='marital_status'".
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower($value_1); //Replaced Upper Cases to Lower Cases.
<i> </i> ?>
<i> </i> <div class="row">
<i> </i> <div class="col-25">
<i> </i> <label for="<?php echo $value_2;?>"><b><?php echo $value;?>: *</b></label>
<i> </i> </div>
<i> </i> <div class="col-75">
<i> </i> <textarea name="<?php echo $value_2;?>" rows="10" cols="30">
<i> </i> <?php
<i> </i> if ($id != '') //This $id is 'post id' & 'user id'.
<i> </i> {
<i> </i> echo ${$value_2};
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> echo "Write about yourself here.";
<i> </i> }
<i> </i> ?>
<i> </i> </textarea>
<i> </i> </div>
<i> </i> </div>
<i> </i> <?php
<i> </i> }
<i> </i> //If current Question's input type is a REQUIRED one and is a RadioButton.
<i> </i> elseif($required_current_count_match == 'True' && $radio_button_current_count_match == 'True')
<i> </i> {
<i> </i> //Need to replace 'Spaces' with '_'. And need to replace Upper Cases with Lower Cases as the 'name=" attributes are in lower cases with Under Scores instead of Spaces. Eg. Form Question Label 'Marital Status" is in form input field attribute "name='marital_status' or "id"='marital_status'".
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower($value_1); //Replaced Upper Cases to Lower Cases.
<i> </i> ?>
<i> </i> <div class="row">
<i> </i> <div class="col-25">
<i> </i> <label for="<?php echo $value_2;?>"><b><?php echo $value;?>: *</b></label>
<i> </i> </div>
<i> </i> <div class="col-75">
<i> </i> <?php
<i> </i> foreach($form_radio_button_number_[$current_radio_button_number] as $value_3)
<i> </i> {
<i> </i> if($id != '' && $value_3 == ${$value_2})
<i> </i> {
<i> </i> //Even <?php echo "$value_3" is fine as both "$value_3" and "${$value_2}" hold same value. ${$value_2} is from database."
<i> </i> ?>
<i> </i> <input type="radio" name="<?php echo $value_2;?>" value="<?php echo ${$value_2};?>" checked><?php echo ${$value_2};?>
<i> </i> <?php
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> ?>
<i> </i> <input type="radio" name="<?php echo $value_2;?>" value="<?php echo $value_3;?>"><?php echo $value_3;?>
<i> </i> <?php
<i> </i> }
<i> </i> }
<i> </i> ?>
<i> </i> </div>
<i> </i> </div>
<i> </i> <?php
<i> </i> }
<i> </i> //If current Question's input type is a REQUIRED one and is a DropDown.
<i> </i> elseif($required_current_count_match == 'True' && $dropdown_current_count_match == 'True')
<i> </i> {
<i> </i> //Need to replace 'Spaces' with '_'. And need to replace Upper Cases with Lower Cases as the 'name=" attributes are in lower cases with Under Scores instead of Spaces. Eg. Form Question Label 'Marital Status" is in form input field attribute "name='marital_status' or "id"='marital_status'".
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower($value_1); //Replaced Upper Cases to Lower Cases.
<i> </i> ?>
<i> </i> <div class="row">
<i> </i> <div class="col-25">
<i> </i> <label for="<?php echo $value_2;?>"><b><?php echo $value;?>: *</b></label>
<i> </i> </div>
<i> </i> <div class="col-75">
<i> </i> <select id="<?php echo $value_2;?>" name="<?php echo $value_2;?>">
<i> </i> <?php
<i> </i> foreach($form_dropdown_number_[$current_drop_down_number] as $value_3)
<i> </i> {
<i> </i> if($id != '' && $value_3 == ${$value_2})
<i> </i> {
<i> </i> //Even <?php echo "$value_3" is fine as both "$value_3" and "${$value_2}" hold same value. ${$value_2} is from database."
<i> </i> ?>
<i> </i> <option value="<?php echo ${$value_2};?>" selected><?php echo ${$value_2};?></option>
<i> </i> <?php
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> ?>
<i> </i> <option value="<?php echo $value_3;?>"><?php echo $value_3;?></option>
<i> </i> <?php
<i> </i> }
<i> </i> }
<i> </i> ?>
<i> </i> </select>
<i> </i> </div>
<i> </i> </div>
<i> </i> <?php
<i> </i> }
<i> </i>}
<i> </i>?>
<i> </i><input type="submit" name="submit" value="Submit" />
<i> </i></form>
<i> </i></div>
<i> </i></body>
<i> </i></html>
<?php
}
?>
<i>
</i><?php
/* CODES FROM NogDog:
https://www.webdeveloper.com/d/387048-which-of-these-is-not-equal-to-operator/15
https://www.webdeveloper.com/d/387053-fatal-error-cannot-use-isset-on-the-result-of-an-expression
*/
$form_questions = array(array('label' => 'First Name','required' => true,'type' => 'text','name' => 'first_name'),
array('label' => 'About Me','required' => false,'type' => 'textarea','name' => 'about_me') // etc....);
foreach($form_questions as $question) {
echo "<label for='{$question['name']}'>{$question['label']}";
if($question['required']) {
echo "*";
}
echo "</label>n";
// some if/else or switch/case statement here based on $question['type']
// to control what form element type gets output...
}
?>
<?php
if(isset($form_questions_required_labels[$required_current_count] && $required_current_count && $required_count_end))
if(isset($form_questions_required_labels[$required_current_count]) && $required_current_count && $required_count_end)
?>
<i>
</i><label for="form_question_labels">Form Question Labels:</label>
<textarea>
</textarea>
<i>
</i><label for="form_question_labels_required">Form Question Labels Required:</label>
<textarea>
<?php echo $form_questions_labels;?>
</textarea>
<i>
</i><label for="first_name_input_type":</label>
<select id="first_name_input_type" name="first_name_input_type">
<option value="text_field">Text Field</option>
<option value="block_text">BlockText</option>
<option value="radio_button">Radio Button</option>
<option value="drop_down">Drop Down</option>
</select>
<label for="gender_input_type":</label>
<select id="gender_input_type" name="gender_input_type">
<option value="text_field">Text Field</option>
<option value="block_text">BlockText</option>
<option value="radio_button">Radio Button</option>
<option value="drop_down">Drop Down</option>
</select>
<label for="tos_input_type":</label>
<select id="tos_input_type" name="tos_input_type">
<option value="text_field">Text Field</option>
<option value="block_text">BlockText</option>
<option value="radio_button">Radio Button</option>
<option value="drop_down">Drop Down</option>
</select>
<i>
</i>$form_questions_labels[]='First Name';
$form_questions_labels[]='Middle Name';
$form_questions_labels[]='Surname';
$form_questions_labels[]='Gender';
$form_questions_labels[]='Age_Range';
$form_questions_labels[]='Tos';
$form_questions_labels_required[]='First Name';
$form_questions_labels_required[]='Surname';
$form_questions_labels_required[]='Gender';
$form_questions_labels_required[]='Age_Range';
$form_questions_labels_required[]='Tos';
$text_fields_labels = array('First Name','Middle Name','Surname');
$radio_buttons_labels = array('Gender');
$dropdowns_labels = array('Tos');
<i>
</i>$radio_buttons_labels = array('Gender');
<i>
</i>$dropdowns_labels = array('Tos');
<i>
</i><label for="radio_button_gender_options">Radio Button Gender Options:</label>
<textarea>
</textarea>
<br>
<br>
<label for="dropdown_tos_options">Dropdown Tos Options:</label>
<textarea>
</textarea>
<i>
</i>$radio_button_gender_options[]='Male';
$radio_button_gender_options[]='Female';
<i>
</i>$radio_button_gender_options = array('Male','Female');
<i>
</i>$dropdown_options = array('Yes','No');
<i>
</i><?php
foreach($form_questions_labels as $form_question_label) //Loop through the whole 'Form Questions' array.
{
//Check if current 'Form Item' is a 'Text Field' or not.
if(in_array("$form_question_label",$text_fields_labels)) //Current 'Form Item' proved to be a 'Text Field'.
{
//Check if current 'Form Item' (Text Field) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Text Field) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Text Field' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>
<input type="text" name="$form_question_label" placeholder="$form_question_label"><br>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Text Field' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>
<input type="text" name="$form_question_label" placeholder="$form_question_label"><br>";
}
}
<i>
</i>$radio_buttons_labels = array('Gender','Tos');
<i>
</i>$radio_button_gender_options[]='Male';
$radio_button_gender_options[]='Female';
<i>
</i>$radio_buttons_labels = array('Gender','Tos');
<i>
</i>$radio_buttons_Gender_Options;
<i>
</i>$radio_buttons_gender_Options;
<i>
</i>$value = $form_question_label;
$value_1 = str_replace("","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i>
</i>//Check if current 'Form Item' is a 'Radio Button' or not.
if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
{
//Check if current 'Form Item' (Radio Button) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Radio Button) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Radio Button' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Radio Button' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>";
}
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace("","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i>
</i><input type="radio" id="Gender" name="Gender" value="Gender">
<label_for="$current_radio_button_option">Gender</label><br>";
<i>
</i><input type="radio" id="gender" name="gender" value="gender">
<label_for="$current_radio_button_option">Gender</label><br>";
<i>
</i>$current_radio_button_options = "$" . "radio_button_" . "$value_2" . "_options";
$current_radio_button_option = "$" . "radio_button_" . "$value_2" . "_option";
<i>
</i>$radio_buttons_labels = array('Gender','Tos');
<i>
</i>//$radio_button_gender_options = array('Male','Female');
$radio_button_gender_options[]='Male';
$radio_button_gender_options[]='Female';
$radio_button_tos_options = array('Yes','No');
<i>
</i><?php
foreach($form_questions_labels as $form_question_label) //Loop through the whole 'Form Questions' array.
{
//Check if current 'Form Item' is a 'Text Field' or not.
if(in_array("$form_question_label",$text_fields_labels)) //Current 'Form Item' proved to be a 'Text Field'.
{
//Check if current 'Form Item' (Text Field) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Text Field) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Text Field' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>
<input type="text" name="$form_question_label" placeholder="$form_question_label"><br>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Text Field' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>
<input type="text" name="$form_question_label" placeholder="$form_question_label"><br>";
}
}
//Check if current 'Form Item' is a 'Radio Button' or not.
if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
{
//Check if current 'Form Item' (Radio Button) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Radio Button) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Radio Button' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Radio Button' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>";
}
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace("","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> foreach($radio_button_{$value_2}_options as $radio_button_{$value_2}_option) //Loop through the whole appropriate 'Radio Buttons' array.
<i> </i> {
<i> </i> echo "<input type="radio" id="$current_radio_button_option" name="$value_2" value="$current_radio_button_option">
<i> </i> <label_for="$current_radio_button_option">$current_radio_button_option</label><br>";
<i> </i> }
<i> </i>}
}
<i>
</i>foreach($radio_button_{$value_2}_options as $radio_button_{$value_2}_option) //Loop through the whole appropriate 'Radio Buttons' array.
<i>
</i>foreach($radio_button_$value_2_options as $radio_button_{$value_2}_option) //Loop through the whole appropriate 'Radio Buttons' array.
<i>
</i><?php
foreach($form_questions_labels as $form_question_label) //Loop through the whole 'Form Questions' array.
{
//Check if current 'Form Item' is a 'Text Field' or not.
if(in_array("$form_question_label",$text_fields_labels)) //Current 'Form Item' proved to be a 'Text Field'.
{
//Check if current 'Form Item' (Text Field) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Text Field) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Text Field' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>
<input type="text" name="$form_question_label" placeholder="$form_question_label"><br>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Text Field' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>
<input type="text" name="$form_question_label" placeholder="$form_question_label"><br>";
}
}
//Check if current 'Form Item' is a 'Radio Button' or not.
if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
{
//Check if current 'Form Item' (Radio Button) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Radio Button) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Radio Button' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Radio Button' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>";
}
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace("","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> foreach($radio_button_$value_2_options as $radio_button_{$value_2}_option) //Loop through the whole appropriate 'Radio Buttons' array.
<i> </i> {
<i> </i> echo "<input type="radio" id="$current_radio_button_option" name="$value_2" value="$current_radio_button_option">
<i> </i> <label_for="$current_radio_button_option">$current_radio_button_option</label><br>";
<i> </i> }
<i> </i>}
}
<i>
</i>foreach($current_radio_button_options as $current_radio_button_option) //Loop through the whole appropriate 'Radio Buttons' array.
<i>
</i> //Check if current 'Form Item' is a 'Radio Button' or not.
if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
{
//Check if current 'Form Item' (Radio Button) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Radio Button) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Radio Button' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Radio Button' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>";
}
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace("","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>
<i> </i> $current_radio_button_options = "$" . "radio_button_" . "$value_2" . "_options";
<i> </i> $current_radio_button_option = "$" . "radio_button_" . "$value_2" . "_option";
<i> </i>
<i> </i> /* THIS DIDN'T WORK
<i> </i> $current_radio_button_options = "$" . "radio_button_" . "{$value_2}" . "_options";
<i> </i> $current_radio_button_option = "$" . "radio_button_" . "{$value_2}" . "_option";
<i> </i> */
<i> </i>
foreach($current_radio_button_options as $current_radio_button_option) //Loop through the whole appropriate 'Radio Buttons' array.
{
echo "<input type="radio" id="$current_radio_button_option" name="$value_2" value="$current_radio_button_option">
<label_for="$current_radio_button_option">$current_radio_button_option</label><br>";
}
}
}
<i>
</i>$current_radio_button_options = "$" . "radio_button_" . "$value_2" . "_options";
$current_radio_button_option = "$" . "radio_button_" . "$value_2" . "_option";
<i>
</i>$current_radio_button_options = "$" . "radio_button_" . "{$value_2}" . "_options";
$current_radio_button_option = "$" . "radio_button_" . "{$value_2}" . "_option";
<i>
</i><?php
$form_questions_labels[]='Title';
$form_questions_labels[]='First Name';
$form_questions_labels[]='Middle Name';
$form_questions_labels[]='Surname';
$form_questions_labels[]='Gender';
$form_questions_labels[]='Tos';
$form_questions_labels_required[]='Title';
$form_questions_labels_required[]='First Name';
$form_questions_labels_required[]='Surname';
$form_questions_labels_required[]='Gender';
$form_questions_labels_required[]='Tos';
$text_fields_labels = array('First Name','Middle Name','Surname');
$radio_buttons_labels = array('Gender','Tos');
//$radio_button_gender_options = array('Male','Female','Male To Female','Female To Male');
$radio_button_gender_options[]='Male';
$radio_button_gender_options[]='Female';
$drop_down_tos_options = array('Yes','No');
?>
<form action="" method="post" enctype="plain/text">
<?php
foreach($form_questions_labels as $form_question_label) //Loop through the whole 'Form Questions' array.
{
//Check if current 'Form Item' is a 'Text Field' or not.
if(in_array("$form_question_label",$text_fields_labels)) //Current 'Form Item' proved to be a 'Text Field'.
{
//Check if current 'Form Item' (Text Field) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Text Field) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Text Field' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>
<input type="text" name="$form_question_label" placeholder="$form_question_label"><br>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Text Field' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>
<input type="text" name="$form_question_label" placeholder="$form_question_label"><br>";
}
}
//Check if current 'Form Item' is a 'Radio Button' or not.
if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
{
//Check if current 'Form Item' (Radio Button) is a 'required' one or not.
if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Radio Button) proved to be a 'required' one.
{
//Added '*' (asterisk) to indicate the 'Radio Button' is a 'required' one.
echo "<label for="$form_question_label">$form_question_label *:</label>";
}
else
{
//Added no '*' (asterisk) to indicate the 'Radio Button' is NOT a 'required' one.
echo "<label for="$form_question_label">$form_question_label:</label>";
}
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace("","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>
<i> </i> $current_radio_button_options = "$" . "radio_button_" . "$value_2" . "_options";
<i> </i> $current_radio_button_option = "$" . "radio_button_" . "$value_2" . "_option";
<i> </i>
<i> </i> /*
<i> </i> $current_radio_button_options = "$" . "radio_button_" . "{$value_2}" . "_options";
<i> </i> $current_radio_button_option = "$" . "radio_button_" . "{$value_2}" . "_option";
<i> </i> */
<i> </i> if($radio_button_gender_options = $current_radio_button_options)
<i> </i> {
<i> </i> echo "They are the same ARRAY";
<i> </i> }
<i> </i>
<i> </i> foreach($current_radio_button_options as $current_radio_button_option) //Loop through the whole appropriate 'Radio Buttons' array.
<i> </i> {
<i> </i> echo "<input type="radio" id="$current_radio_button_option" name="$value_2" value="$current_radio_button_option">
<i> </i> <label_for="$current_radio_button_option">$current_radio_button_option</label><br>";
<i> </i> }
<i> </i>}
}
<i>
</i>$form_questions_labels[]='Title';
$form_questions_labels[]='First Name';
$form_questions_labels[]='Middle Name';
$form_questions_labels[]='Surname';
$form_questions_labels[]='Gender';
$form_questions_labels[]='Tos';
$form_questions_labels_required[]='Title';
$form_questions_labels_required[]='First Name';
$form_questions_labels_required[]='Surname';
$form_questions_labels_required[]='Gender';
$form_questions_labels_required[]='Tos';
$text_fields_labels = array('First Name','Middle Name','Surname');
$radio_buttons_labels = array('Gender','Tos');
//$radio_button_gender_options = array('Male','Female');
$radio_button_gender_options[]='Male';
$radio_button_gender_options[]='Female';
$dropdown_tos_options = array('Yes','No');
<i>
</i>//Check if current 'Form Item' is a 'Radio Button' or not.
if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
{
<i>
</i><!DOCTYPE HTML">
<html>
<head>
<meta name="viewport" content="width-device=width, initial-scale=1">
</head>
<body>
<?php
$form_questions_labels[]='Title';
$form_questions_labels[]='First Name';
$form_questions_labels[]='Middle Name';
$form_questions_labels[]='Surname';
$form_questions_labels[]='Gender';
$form_questions_labels[]='Age_Range';
$form_questions_labels[]='Marital_Status';
$form_questions_labels[]='Working_Status';
$form_questions_labels[]='Tos';
$form_questions_labels_required[]='Title';
$form_questions_labels_required[]='First Name';
$form_questions_labels_required[]='Surname';
$form_questions_labels_required[]='Gender';
$form_questions_labels_required[]='Age_Range';
$form_questions_labels_required[]='Marital_Status';
$form_questions_labels_required[]='Working_Status';
$form_questions_labels_required[]='Tos';
$text_fields_labels = array('First Name','Middle Name','Surname');
$radio_buttons_labels = array('Gender','Tos');
$drop_downs_labels = array('Marital Status','Working Status');
/*
$i=1;
$options_radio_button_[$i] = array('Male','Female','Male To Female','Female To Male');
$i=2;
$options_radio_button_[$i] = array('Yes','No');
*/
$i=1;
$options_drop_down_[$i] = array('Single','Married','Divorced','Widow');
$i=2;
$options_drop_down_[$i] = array('Selfemployed','Employed','Unemployed');
//Gender Options
$i=1;
$options_radio_button_[$i][]='Male';
$options_radio_button_[$i][]='Female';
$options_radio_button_[$i][]='Male To Female';
$options_radio_button_[$i][]='Female To Male';
$total_options_radio_button_[$i] = count($options_radio_button_[$i]);//4
echo "Line 55: $total_options_radio_button_[$i]<br>";
//Tos Options
$i=2;
$options_radio_button_[$i][]='Yes';
$options_radio_button_[$i][]='No';
$total_options_radio_button_[$i] = count($options_radio_button_[$i]);//2
echo "Line 61: $total_options_radio_button_[$i]<br>";
//Marital Status Options
$i=1;
$options_drop_down_[$i][]='Single';
$options_drop_down_[$i][]='Married';
$options_drop_down_[$i][]='Divorced';
$options_drop_down_[$i][]='Widow';
//Working Status Options
$i=2;
$options_drop_down_[$i][]='Selfemployed';
$options_drop_down_[$i][]='Employed';
$options_drop_down_[$i][]='Unemployed';
$total_form_questions_labels = 9;
$total_form_questions_labels_required = 8;
$total_text_fields_labels = 3;
$total_radio_buttons_labels = count($radio_buttons_labels);//2
echo "Line 78: $total_radio_buttons_labels<br>";
?>
<form action="" method="post" enctype="plain/text">
<?php
foreach($form_questions_labels as $form_question_label) //Loop through the whole 'Form Questions' array.
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>//Check if current 'Form Item' is a 'Text Field' or not.
<i> </i>if(in_array("$form_question_label",$text_fields_labels)) //Current 'Form Item' proved to be a 'Text Field'.
<i> </i>{
<i> </i> //Check if current 'Form Item' (Text Field) is a 'required' one or not.
<i> </i> if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Text Field) proved to be a 'required' one.
<i> </i> {
<i> </i> //Added '*' (asterisk) to indicate the 'Text Field' is a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label *:</label>
<i> </i> <input type="text" name="$value_2" placeholder="$form_question_label"><br>";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Added no '*' (asterisk) to indicate the 'Text Field' is NOT a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label:</label>
<i> </i> <input type="text" name="$value_2" placeholder="$form_question_label"><br>";
<i> </i> }
<i> </i>}
<i> </i>//Check if current 'Form Item' is a 'Radio Button' or not.
<i> </i>if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
<i> </i>{
<i> </i> //Check if current 'Form Item' (Radio Button) is a 'required' one or not.
<i> </i> if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Radio Button) proved to be a 'required' one.
<i> </i> {
<i> </i> //Added '*' (asterisk) to indicate the 'Radio Button' is a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label *:</label><br>";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Added no '*' (asterisk) to indicate the 'Radio Button' is NOT a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label:</label><br>";
<i> </i> }
<i> </i> /* I GET ARRAY TO STRING CONVERSION ERROR
<i> </i> for($i = 0; $i <= $total_radio_buttons_labels; $i++)
<i> </i> {
<i> </i> if($form_question_label == $radio_buttons_labels[$i]) //eg. 'Gender'.
<i> </i> {
<i> </i> for ($ii = 1; $ii <= $total_options_radio_button_[$ii]; $ii++)
<i> </i> {
<i> </i> echo "<input type="radio" id="$options_radio_button_[$ii]" name="$value_2" value="$options_radio_button_[$ii]">
<i> </i> <label_for="$options_radio_button_[$ii]">$options_radio_button_[$ii]</label><br>";
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i> */
<i> </i> /* I GET ARRAY TO STRING CONVERSION ERROR
<i> </i> for($i = 0; $i <= $total_radio_buttons_labels; $i++)
<i> </i> {
<i> </i> if($form_question_label == $radio_buttons_labels[$i]) //eg. 'Gender'.
<i> </i> {
<i> </i> for ($ii = 1; $ii <= $total_options_radio_button_[$ii]; $ii++)
<i> </i> {
<i> </i> echo $options_radio_button_number = "$options_radio_button_[$ii]";
<i> </i> echo "<input type="radio" id="$options_radio_button_number" name="$value_2" value="$options_radio_button_number">
<i> </i> <label_for="$options_radio_button_number">$options_radio_button_number</label><br>";
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i> */
<i> </i> //THIS WORKED OVER THE ABOVE TWO 'FOR LOOPS'.
<i> </i> $i = 0;
<i> </i> foreach($radio_buttons_labels as $radio_button_label) //$radio_buttons_labels = ('Gender','Tos');
<i> </i> {
<i> </i> if($form_question_label == $radio_button_label) //eg. 'Gender'.
<i> </i> {
<i> </i> $i++;
<i> </i> foreach($options_radio_button_[$i] as $option_radio_button_[$i])
<i> </i> {
<i> </i> echo "<input type="radio" id="$option_radio_button_[$i]" name="$value_2" value="$option_radio_button_[$i]">
<i> </i> <label_for="$option_radio_button_[$i]">$option_radio_button_[$i]</label><br>";
<i> </i> }
<i> </i> }
<i> </i> $i++;
<i> </i> }
<i> </i>}
}
?>
0.1.9 — BETA 4.27