title: Removing extra quotation marks from a string
body: <p>so I have a lot of problematic values in my database.
  There are two columns, one is email. Some emails are stored in this way <strong>"foo@foobar.com</strong>, the quotation mark at the starting is useless. I want that to be converted to <strong>foo@foobar.com</strong>.
  Similarly, there's another field known as company, which has data like this <strong>stackoverflow"</strong>, the quotation mark at the ending needs to be removed as well.</p>
  
  <p>I have written this code, but for some reason this doesn't removes the quotation marks.
  What am I doing wrong ?
  Any suggestions are welcome.</p>
  
  <pre><code>global $conn;
          try
          {
              $statement= $conn-&gt;query("SELECT * from emails");
              $statement-&gt;setFetchMode(PDO::FETCH_ASSOC);
              while($rows = $statement-&gt;fetch())
              {
                  $email=$rows['emailid'];
                  $company=$rows['company'];
                  $len = strlen($company);
                  if($email{0} == '"')
                  {
                      //problem at start
                      //fix there.
                      $updated = substr($email, 1);
                      //now update
                      try
                      {
                          $statement = $conn-&gt;prepare("UPDATE emails set emailid = :email where indexid = :indexid");
                          $statement-&gt;bindParam(':email',$updated);
                          $statement-&gt;bindParam(':indexid',$row['indexid']);
                          $statement-&gt;execute();
                          $statement-&gt;closeCursor();
                          return true;
                      }
                      catch(PDOException $e)
                      {
                          echo $e-&gt;getMessage();
                      }
                  }
                  elseif($company{$len-1} == '"')
                  {
                      $updated = substr($company, 0, -1);
                      //now update
                      try
                      {
                          $statement = $conn-&gt;prepare("UPDATE emails set company = :company where indexid = :indexid");
                          $statement-&gt;bindParam(':company',$updated);
                          $statement-&gt;bindParam(':indexid',$row['indexid']);
                          $statement-&gt;execute();
                          $statement-&gt;closeCursor();
                          return true;
                      }
                      catch(PDOException $e)
                      {
                          echo $e-&gt;getMessage();
                      }
                  }
                  else
                  {
                      echo "";
                  }
              }
          }
          catch(PDOException $e)
          {
              echo $e-&gt;getMessage();
          }
  </code></pre>