How to change a n value for a value like X












7















I have a webpage for homework. Students fill in the boxes, then click send to send the form.
My php thankyou file gets the answers and sends to my email. I download the emails and use Python to check each answer against the correct answer, line for line using readlines().



This morning I noticed, one student missed the first part, 1 to 5 'choose the right word from the table.' They should just enter a letter, A to E, in each textbox, G1 to G5. The email sent by php then contains 5 empty lines, n, where the answers should be.



Because students often press enter in strange places, I run a Python script to get rid of empty lines in the emails after downloading.



So I would like to get php to put say X if a textbox is empty, before it sends the email.



The first part of the thankyou.php looks like this:



//should mail the contact form
<?php
$studentnr = $_POST['sn'];
$q1 = $_POST['G1'];
$q2 = $_POST['G2'];
$q3 = $_POST['G3'];
$q4 = $_POST['G4'];
$q5 = $_POST['G5'];


What I would like to do in php is something along the lines of:



for i in range(1, 6):  
answer = $q + str(i)
if answer = '':
answer = 'X'


but that would be Python. What is the right way to do this in php?



I think this should be done after collecting all the $qs in the php script, but before making the body of the email:



$body = "

Studentnr = ".$studentnr."
".$q1."
".$q2."
".$q3."
".$q4."
".$q5."
";


Very grateful for any tips!



Edit: this is an actual thankyou.php with the loop to change '' for X, but all I get now in the email is: Studentnr = 1725010999, nothing else. How to tweak this? I just entered the student number and left all other boxes empty, so I was expecting a lot of Xs. I am not getting any errors in the error log of my php directory on the webpage host. Maybe a ; missing somewhere?



//should mail the contact form
<?php
$studentnr = $_POST['sn'];
$q1 = $_POST['G1'];
$q2 = $_POST['G2'];
$q3 = $_POST['G3'];
$q4 = $_POST['G4'];
$q5 = $_POST['G5'];
$q6 = $_POST['G6'];
$q7 = $_POST['G7'];
$q8 = $_POST['G8'];
$q9 = $_POST['G9'];
$q10 = $_POST['G10'];
$q11 = $_POST['G11'];
$q12 = $_POST['G12'];
$q13 = $_POST['G13'];
$q14 = $_POST['G14'];
$q15 = $_POST['G15'];
$q16 = $_POST['G16'];
$q17 = $_POST['G17'];
$q18 = $_POST['G18'];

for ($i=1; $i <= 18; $i++) {
if (${"q$i"} == '') ${"q$i"} = 'X';
}

$body = "

Studentnr = ".$studentnr."
".$q1."
".$q2."
".$q3."
".$q4."
".$q5."
".$q6."
".$q7."
".$q8."
".$q9."
".$q10."
".$q11."
".$q12."
".$q13."
".$q14."
".$q15."
".$q16."
".$q17."
".$q18."
";


$to1 = "myemail@foxmail.com";

$subject = $studentnr . "sWeek1";
$headers = "From: peter@mypage.comrn";
$headers .= 'Content-Type: text/plain; charset=utf-8';

mail($to1, $subject, $body, $headers);

header("Location: email_success.php");

?>


Any more tips please?










share|improve this question





























    7















    I have a webpage for homework. Students fill in the boxes, then click send to send the form.
    My php thankyou file gets the answers and sends to my email. I download the emails and use Python to check each answer against the correct answer, line for line using readlines().



    This morning I noticed, one student missed the first part, 1 to 5 'choose the right word from the table.' They should just enter a letter, A to E, in each textbox, G1 to G5. The email sent by php then contains 5 empty lines, n, where the answers should be.



    Because students often press enter in strange places, I run a Python script to get rid of empty lines in the emails after downloading.



    So I would like to get php to put say X if a textbox is empty, before it sends the email.



    The first part of the thankyou.php looks like this:



    //should mail the contact form
    <?php
    $studentnr = $_POST['sn'];
    $q1 = $_POST['G1'];
    $q2 = $_POST['G2'];
    $q3 = $_POST['G3'];
    $q4 = $_POST['G4'];
    $q5 = $_POST['G5'];


    What I would like to do in php is something along the lines of:



    for i in range(1, 6):  
    answer = $q + str(i)
    if answer = '':
    answer = 'X'


    but that would be Python. What is the right way to do this in php?



    I think this should be done after collecting all the $qs in the php script, but before making the body of the email:



    $body = "

    Studentnr = ".$studentnr."
    ".$q1."
    ".$q2."
    ".$q3."
    ".$q4."
    ".$q5."
    ";


    Very grateful for any tips!



    Edit: this is an actual thankyou.php with the loop to change '' for X, but all I get now in the email is: Studentnr = 1725010999, nothing else. How to tweak this? I just entered the student number and left all other boxes empty, so I was expecting a lot of Xs. I am not getting any errors in the error log of my php directory on the webpage host. Maybe a ; missing somewhere?



    //should mail the contact form
    <?php
    $studentnr = $_POST['sn'];
    $q1 = $_POST['G1'];
    $q2 = $_POST['G2'];
    $q3 = $_POST['G3'];
    $q4 = $_POST['G4'];
    $q5 = $_POST['G5'];
    $q6 = $_POST['G6'];
    $q7 = $_POST['G7'];
    $q8 = $_POST['G8'];
    $q9 = $_POST['G9'];
    $q10 = $_POST['G10'];
    $q11 = $_POST['G11'];
    $q12 = $_POST['G12'];
    $q13 = $_POST['G13'];
    $q14 = $_POST['G14'];
    $q15 = $_POST['G15'];
    $q16 = $_POST['G16'];
    $q17 = $_POST['G17'];
    $q18 = $_POST['G18'];

    for ($i=1; $i <= 18; $i++) {
    if (${"q$i"} == '') ${"q$i"} = 'X';
    }

    $body = "

    Studentnr = ".$studentnr."
    ".$q1."
    ".$q2."
    ".$q3."
    ".$q4."
    ".$q5."
    ".$q6."
    ".$q7."
    ".$q8."
    ".$q9."
    ".$q10."
    ".$q11."
    ".$q12."
    ".$q13."
    ".$q14."
    ".$q15."
    ".$q16."
    ".$q17."
    ".$q18."
    ";


    $to1 = "myemail@foxmail.com";

    $subject = $studentnr . "sWeek1";
    $headers = "From: peter@mypage.comrn";
    $headers .= 'Content-Type: text/plain; charset=utf-8';

    mail($to1, $subject, $body, $headers);

    header("Location: email_success.php");

    ?>


    Any more tips please?










    share|improve this question



























      7












      7








      7








      I have a webpage for homework. Students fill in the boxes, then click send to send the form.
      My php thankyou file gets the answers and sends to my email. I download the emails and use Python to check each answer against the correct answer, line for line using readlines().



      This morning I noticed, one student missed the first part, 1 to 5 'choose the right word from the table.' They should just enter a letter, A to E, in each textbox, G1 to G5. The email sent by php then contains 5 empty lines, n, where the answers should be.



      Because students often press enter in strange places, I run a Python script to get rid of empty lines in the emails after downloading.



      So I would like to get php to put say X if a textbox is empty, before it sends the email.



      The first part of the thankyou.php looks like this:



      //should mail the contact form
      <?php
      $studentnr = $_POST['sn'];
      $q1 = $_POST['G1'];
      $q2 = $_POST['G2'];
      $q3 = $_POST['G3'];
      $q4 = $_POST['G4'];
      $q5 = $_POST['G5'];


      What I would like to do in php is something along the lines of:



      for i in range(1, 6):  
      answer = $q + str(i)
      if answer = '':
      answer = 'X'


      but that would be Python. What is the right way to do this in php?



      I think this should be done after collecting all the $qs in the php script, but before making the body of the email:



      $body = "

      Studentnr = ".$studentnr."
      ".$q1."
      ".$q2."
      ".$q3."
      ".$q4."
      ".$q5."
      ";


      Very grateful for any tips!



      Edit: this is an actual thankyou.php with the loop to change '' for X, but all I get now in the email is: Studentnr = 1725010999, nothing else. How to tweak this? I just entered the student number and left all other boxes empty, so I was expecting a lot of Xs. I am not getting any errors in the error log of my php directory on the webpage host. Maybe a ; missing somewhere?



      //should mail the contact form
      <?php
      $studentnr = $_POST['sn'];
      $q1 = $_POST['G1'];
      $q2 = $_POST['G2'];
      $q3 = $_POST['G3'];
      $q4 = $_POST['G4'];
      $q5 = $_POST['G5'];
      $q6 = $_POST['G6'];
      $q7 = $_POST['G7'];
      $q8 = $_POST['G8'];
      $q9 = $_POST['G9'];
      $q10 = $_POST['G10'];
      $q11 = $_POST['G11'];
      $q12 = $_POST['G12'];
      $q13 = $_POST['G13'];
      $q14 = $_POST['G14'];
      $q15 = $_POST['G15'];
      $q16 = $_POST['G16'];
      $q17 = $_POST['G17'];
      $q18 = $_POST['G18'];

      for ($i=1; $i <= 18; $i++) {
      if (${"q$i"} == '') ${"q$i"} = 'X';
      }

      $body = "

      Studentnr = ".$studentnr."
      ".$q1."
      ".$q2."
      ".$q3."
      ".$q4."
      ".$q5."
      ".$q6."
      ".$q7."
      ".$q8."
      ".$q9."
      ".$q10."
      ".$q11."
      ".$q12."
      ".$q13."
      ".$q14."
      ".$q15."
      ".$q16."
      ".$q17."
      ".$q18."
      ";


      $to1 = "myemail@foxmail.com";

      $subject = $studentnr . "sWeek1";
      $headers = "From: peter@mypage.comrn";
      $headers .= 'Content-Type: text/plain; charset=utf-8';

      mail($to1, $subject, $body, $headers);

      header("Location: email_success.php");

      ?>


      Any more tips please?










      share|improve this question
















      I have a webpage for homework. Students fill in the boxes, then click send to send the form.
      My php thankyou file gets the answers and sends to my email. I download the emails and use Python to check each answer against the correct answer, line for line using readlines().



      This morning I noticed, one student missed the first part, 1 to 5 'choose the right word from the table.' They should just enter a letter, A to E, in each textbox, G1 to G5. The email sent by php then contains 5 empty lines, n, where the answers should be.



      Because students often press enter in strange places, I run a Python script to get rid of empty lines in the emails after downloading.



      So I would like to get php to put say X if a textbox is empty, before it sends the email.



      The first part of the thankyou.php looks like this:



      //should mail the contact form
      <?php
      $studentnr = $_POST['sn'];
      $q1 = $_POST['G1'];
      $q2 = $_POST['G2'];
      $q3 = $_POST['G3'];
      $q4 = $_POST['G4'];
      $q5 = $_POST['G5'];


      What I would like to do in php is something along the lines of:



      for i in range(1, 6):  
      answer = $q + str(i)
      if answer = '':
      answer = 'X'


      but that would be Python. What is the right way to do this in php?



      I think this should be done after collecting all the $qs in the php script, but before making the body of the email:



      $body = "

      Studentnr = ".$studentnr."
      ".$q1."
      ".$q2."
      ".$q3."
      ".$q4."
      ".$q5."
      ";


      Very grateful for any tips!



      Edit: this is an actual thankyou.php with the loop to change '' for X, but all I get now in the email is: Studentnr = 1725010999, nothing else. How to tweak this? I just entered the student number and left all other boxes empty, so I was expecting a lot of Xs. I am not getting any errors in the error log of my php directory on the webpage host. Maybe a ; missing somewhere?



      //should mail the contact form
      <?php
      $studentnr = $_POST['sn'];
      $q1 = $_POST['G1'];
      $q2 = $_POST['G2'];
      $q3 = $_POST['G3'];
      $q4 = $_POST['G4'];
      $q5 = $_POST['G5'];
      $q6 = $_POST['G6'];
      $q7 = $_POST['G7'];
      $q8 = $_POST['G8'];
      $q9 = $_POST['G9'];
      $q10 = $_POST['G10'];
      $q11 = $_POST['G11'];
      $q12 = $_POST['G12'];
      $q13 = $_POST['G13'];
      $q14 = $_POST['G14'];
      $q15 = $_POST['G15'];
      $q16 = $_POST['G16'];
      $q17 = $_POST['G17'];
      $q18 = $_POST['G18'];

      for ($i=1; $i <= 18; $i++) {
      if (${"q$i"} == '') ${"q$i"} = 'X';
      }

      $body = "

      Studentnr = ".$studentnr."
      ".$q1."
      ".$q2."
      ".$q3."
      ".$q4."
      ".$q5."
      ".$q6."
      ".$q7."
      ".$q8."
      ".$q9."
      ".$q10."
      ".$q11."
      ".$q12."
      ".$q13."
      ".$q14."
      ".$q15."
      ".$q16."
      ".$q17."
      ".$q18."
      ";


      $to1 = "myemail@foxmail.com";

      $subject = $studentnr . "sWeek1";
      $headers = "From: peter@mypage.comrn";
      $headers .= 'Content-Type: text/plain; charset=utf-8';

      mail($to1, $subject, $body, $headers);

      header("Location: email_success.php");

      ?>


      Any more tips please?







      php






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 40 mins ago







      Pedroski

















      asked 3 hours ago









      PedroskiPedroski

      1725




      1725
























          2 Answers
          2






          active

          oldest

          votes


















          4














          You can do that like this:



             for($i=1; $i <= 5; $i++) {
          $answer= ${'q' . $i};
          if($answer=='') $answer='X';
          }


          Edit:
          If you just only need to update value, you can do that like this,



             for($i=1; $i <= 5; $i++) {
          if(${'q' . $i}=='') ${'q' . $i}='X';
          }





          share|improve this answer


























          • Thanks! It occurred to me that I need to reassign the $qs at the end. Like this maybe: for($i=1; $i <= 5; $i++) { $answer= ${'q' . $i}; if($answer=='') $answer='X'; ${'q' . $i} = $answer; } Will that be OK like that??

            – Pedroski
            2 hours ago













          • Oh yes I just converted the python code as you requested. if you wanna replace with X just replace them directly on if statement. I ll update my answer.

            – Whatatimetobealive
            2 hours ago



















          3














          If you want to change any of the $q* variables to 'X' if they are empty, you can use PHPs variable variables to do that. For example:



          $q1 = '';
          $q2 = 'A';
          $q3 = '';
          $q4 = 'E';
          $q5 = 'D';
          for ($i=1; $i <= 5; $i++) {
          if (${"q$i"} == '') ${"q$i"} = 'X';
          }
          echo "$q1n";
          echo "$q2n";
          echo "$q3n";
          echo "$q4n";
          echo "$q5n";


          Output:



          X
          A
          X
          E
          D


          Demo on 3v4l.org






          share|improve this answer


























          • So I don't need to reassign variables via $answer, just directly reassign ${"q$i"} = 'X'; That's great, I'll try it asap!

            – Pedroski
            2 hours ago











          • @Pedroski no, no need to use an intermediate variable, you can do it all in one line.

            – Nick
            2 hours ago











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54917530%2fhow-to-change-a-n-value-for-a-value-like-x%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          You can do that like this:



             for($i=1; $i <= 5; $i++) {
          $answer= ${'q' . $i};
          if($answer=='') $answer='X';
          }


          Edit:
          If you just only need to update value, you can do that like this,



             for($i=1; $i <= 5; $i++) {
          if(${'q' . $i}=='') ${'q' . $i}='X';
          }





          share|improve this answer


























          • Thanks! It occurred to me that I need to reassign the $qs at the end. Like this maybe: for($i=1; $i <= 5; $i++) { $answer= ${'q' . $i}; if($answer=='') $answer='X'; ${'q' . $i} = $answer; } Will that be OK like that??

            – Pedroski
            2 hours ago













          • Oh yes I just converted the python code as you requested. if you wanna replace with X just replace them directly on if statement. I ll update my answer.

            – Whatatimetobealive
            2 hours ago
















          4














          You can do that like this:



             for($i=1; $i <= 5; $i++) {
          $answer= ${'q' . $i};
          if($answer=='') $answer='X';
          }


          Edit:
          If you just only need to update value, you can do that like this,



             for($i=1; $i <= 5; $i++) {
          if(${'q' . $i}=='') ${'q' . $i}='X';
          }





          share|improve this answer


























          • Thanks! It occurred to me that I need to reassign the $qs at the end. Like this maybe: for($i=1; $i <= 5; $i++) { $answer= ${'q' . $i}; if($answer=='') $answer='X'; ${'q' . $i} = $answer; } Will that be OK like that??

            – Pedroski
            2 hours ago













          • Oh yes I just converted the python code as you requested. if you wanna replace with X just replace them directly on if statement. I ll update my answer.

            – Whatatimetobealive
            2 hours ago














          4












          4








          4







          You can do that like this:



             for($i=1; $i <= 5; $i++) {
          $answer= ${'q' . $i};
          if($answer=='') $answer='X';
          }


          Edit:
          If you just only need to update value, you can do that like this,



             for($i=1; $i <= 5; $i++) {
          if(${'q' . $i}=='') ${'q' . $i}='X';
          }





          share|improve this answer















          You can do that like this:



             for($i=1; $i <= 5; $i++) {
          $answer= ${'q' . $i};
          if($answer=='') $answer='X';
          }


          Edit:
          If you just only need to update value, you can do that like this,



             for($i=1; $i <= 5; $i++) {
          if(${'q' . $i}=='') ${'q' . $i}='X';
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 3 hours ago









          WhatatimetobealiveWhatatimetobealive

          676411




          676411













          • Thanks! It occurred to me that I need to reassign the $qs at the end. Like this maybe: for($i=1; $i <= 5; $i++) { $answer= ${'q' . $i}; if($answer=='') $answer='X'; ${'q' . $i} = $answer; } Will that be OK like that??

            – Pedroski
            2 hours ago













          • Oh yes I just converted the python code as you requested. if you wanna replace with X just replace them directly on if statement. I ll update my answer.

            – Whatatimetobealive
            2 hours ago



















          • Thanks! It occurred to me that I need to reassign the $qs at the end. Like this maybe: for($i=1; $i <= 5; $i++) { $answer= ${'q' . $i}; if($answer=='') $answer='X'; ${'q' . $i} = $answer; } Will that be OK like that??

            – Pedroski
            2 hours ago













          • Oh yes I just converted the python code as you requested. if you wanna replace with X just replace them directly on if statement. I ll update my answer.

            – Whatatimetobealive
            2 hours ago

















          Thanks! It occurred to me that I need to reassign the $qs at the end. Like this maybe: for($i=1; $i <= 5; $i++) { $answer= ${'q' . $i}; if($answer=='') $answer='X'; ${'q' . $i} = $answer; } Will that be OK like that??

          – Pedroski
          2 hours ago







          Thanks! It occurred to me that I need to reassign the $qs at the end. Like this maybe: for($i=1; $i <= 5; $i++) { $answer= ${'q' . $i}; if($answer=='') $answer='X'; ${'q' . $i} = $answer; } Will that be OK like that??

          – Pedroski
          2 hours ago















          Oh yes I just converted the python code as you requested. if you wanna replace with X just replace them directly on if statement. I ll update my answer.

          – Whatatimetobealive
          2 hours ago





          Oh yes I just converted the python code as you requested. if you wanna replace with X just replace them directly on if statement. I ll update my answer.

          – Whatatimetobealive
          2 hours ago













          3














          If you want to change any of the $q* variables to 'X' if they are empty, you can use PHPs variable variables to do that. For example:



          $q1 = '';
          $q2 = 'A';
          $q3 = '';
          $q4 = 'E';
          $q5 = 'D';
          for ($i=1; $i <= 5; $i++) {
          if (${"q$i"} == '') ${"q$i"} = 'X';
          }
          echo "$q1n";
          echo "$q2n";
          echo "$q3n";
          echo "$q4n";
          echo "$q5n";


          Output:



          X
          A
          X
          E
          D


          Demo on 3v4l.org






          share|improve this answer


























          • So I don't need to reassign variables via $answer, just directly reassign ${"q$i"} = 'X'; That's great, I'll try it asap!

            – Pedroski
            2 hours ago











          • @Pedroski no, no need to use an intermediate variable, you can do it all in one line.

            – Nick
            2 hours ago
















          3














          If you want to change any of the $q* variables to 'X' if they are empty, you can use PHPs variable variables to do that. For example:



          $q1 = '';
          $q2 = 'A';
          $q3 = '';
          $q4 = 'E';
          $q5 = 'D';
          for ($i=1; $i <= 5; $i++) {
          if (${"q$i"} == '') ${"q$i"} = 'X';
          }
          echo "$q1n";
          echo "$q2n";
          echo "$q3n";
          echo "$q4n";
          echo "$q5n";


          Output:



          X
          A
          X
          E
          D


          Demo on 3v4l.org






          share|improve this answer


























          • So I don't need to reassign variables via $answer, just directly reassign ${"q$i"} = 'X'; That's great, I'll try it asap!

            – Pedroski
            2 hours ago











          • @Pedroski no, no need to use an intermediate variable, you can do it all in one line.

            – Nick
            2 hours ago














          3












          3








          3







          If you want to change any of the $q* variables to 'X' if they are empty, you can use PHPs variable variables to do that. For example:



          $q1 = '';
          $q2 = 'A';
          $q3 = '';
          $q4 = 'E';
          $q5 = 'D';
          for ($i=1; $i <= 5; $i++) {
          if (${"q$i"} == '') ${"q$i"} = 'X';
          }
          echo "$q1n";
          echo "$q2n";
          echo "$q3n";
          echo "$q4n";
          echo "$q5n";


          Output:



          X
          A
          X
          E
          D


          Demo on 3v4l.org






          share|improve this answer















          If you want to change any of the $q* variables to 'X' if they are empty, you can use PHPs variable variables to do that. For example:



          $q1 = '';
          $q2 = 'A';
          $q3 = '';
          $q4 = 'E';
          $q5 = 'D';
          for ($i=1; $i <= 5; $i++) {
          if (${"q$i"} == '') ${"q$i"} = 'X';
          }
          echo "$q1n";
          echo "$q2n";
          echo "$q3n";
          echo "$q4n";
          echo "$q5n";


          Output:



          X
          A
          X
          E
          D


          Demo on 3v4l.org







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 3 hours ago









          NickNick

          33.2k132042




          33.2k132042













          • So I don't need to reassign variables via $answer, just directly reassign ${"q$i"} = 'X'; That's great, I'll try it asap!

            – Pedroski
            2 hours ago











          • @Pedroski no, no need to use an intermediate variable, you can do it all in one line.

            – Nick
            2 hours ago



















          • So I don't need to reassign variables via $answer, just directly reassign ${"q$i"} = 'X'; That's great, I'll try it asap!

            – Pedroski
            2 hours ago











          • @Pedroski no, no need to use an intermediate variable, you can do it all in one line.

            – Nick
            2 hours ago

















          So I don't need to reassign variables via $answer, just directly reassign ${"q$i"} = 'X'; That's great, I'll try it asap!

          – Pedroski
          2 hours ago





          So I don't need to reassign variables via $answer, just directly reassign ${"q$i"} = 'X'; That's great, I'll try it asap!

          – Pedroski
          2 hours ago













          @Pedroski no, no need to use an intermediate variable, you can do it all in one line.

          – Nick
          2 hours ago





          @Pedroski no, no need to use an intermediate variable, you can do it all in one line.

          – Nick
          2 hours ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54917530%2fhow-to-change-a-n-value-for-a-value-like-x%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Plaza Victoria

          Puebla de Zaragoza

          Musa