title: How can i get result from PHP fetch assoc
body: <pre><code>// Request password
  
  $app-&gt;get('/api/admin/forgot', function(Request $request, Response $response){
  
  $email = $request-&gt;getParam('email');
  $sql = "SELECT admin_password FROM administrators WHERE admin_email = '$email' ";
  
  try{
  
      $db = new db();
      $db = $db-&gt;connect();
      $stmt =  $db-&gt;query($sql);
      $admin = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
  
      $db = null;
  
      if($admin == null){
          echo json_encode(array(
                                  "errno" =&gt; 1,
                                  "message" =&gt; "No account",
                              )
                          );
          return;
  
      }
  
      echo $admin;
      require_once "vendor/autoload.php";
  
      //PHPMailer Object
      $mail = new PHPMailer;
  
      //From email address and name
      $mail-&gt;From = "contact@SMS.com";
      $mail-&gt;FromName = "SAMPLES Management Software";
      //To address and name
      $mail-&gt;addAddress($email); 
      //Address to which recipient will reply
      $mail-&gt;addReplyTo("contact@SMS.com", "SAMPLE Management Software");
      //Send HTML or Plain Text email
      $mail-&gt;isHTML(true);
  
      $mail-&gt;Subject = "Password recovery";
      $mail-&gt;Body = "&lt;h3&gt;Password recovery&lt;h3&gt;&lt;/br&gt;&lt;p&gt;Hi there, your password is '$admin'&lt;/p&gt;";
  
      if(!$mail-&gt;send()) {
          echo json_encode(array(
                                  "errno" =&gt; 0,
                                  "message" =&gt; "Email not sent.",
                                  )
                          );
  
      } else {
          echo json_encode(array(
                                  "errno" =&gt; 0,
                                  "message" =&gt; "Email sent.",
                                  )
                          );
      }
  
  } catch(PDOException $e) {
  
      echo json_encode(array(
                              "errno" =&gt; 1,
                              "feedback" =&gt; $e-&gt;getMessage(),
                              "message" =&gt; "Error occured",
                              )
                      );  
  }
  
  }
  );
  </code></pre>
  
  <p>Okay so i have this code to retrieve passwords and send to mail directly, it works great and i get the mail but the only problem is i am getting the password as 'array'. The password is $admin. Any help? Thanks in advance</p>