title: How to get array values as return values from php REST api request?
body: <p>This question has already being asked but I need a solution that is applicable to my problem. I was able to send values through my php REST api but only a single value was returned.</p>
  
  <p>I want to be able to get all the array values from a curl request.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>if(isset($_POST['btn-login']))
  {
  
      $licence = $_POST['licence'];
  
  
          $ch = curl_init('http://totallightschools.com/apis/User/login.php?licence='.$licence);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          $response = curl_exec($ch);
          curl_close($ch);
          $data   = json_decode($response,true);
          if($data['status'] == true)
          {
          $_SESSION['licence'] = $data['licence'];
          echo $_SESSION['period'] = $data['period'];
          echo $_SESSION['user'] = $data['user'];
          echo $pin = $_SESSION['licence'];
              //echo "yes";
              //header("Location: setup.php?License=".$pin .'&amp;period='.$_SESSION['period'].'&amp;user='.$_SESSION['user']);
          }else
          {
              echo $data['message'];
          }
  
  
  }
  </code></pre>
  
  <p>And for my api url</p>
  
  <pre><code>if($stmt-&gt;rowCount() &gt; 0){
      // get retrieved row
      $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
      // create array
      $user_arr=array(
          "status" =&gt; true,
          "message" =&gt; "Successfully Validated!",
          "id" =&gt; $row['id'],
          "licence" =&gt; $row['licence'],
          "period" =&gt; $row['period'],
          "user" =&gt; $row['users']
      );
  }
  else{
      $user_arr=array(
          "status" =&gt; false,
          "message" =&gt; "Invalid Licence Key Entered. Please contact the software company.",
      );
  }
  // make it json format
  print_r(json_encode($user_arr));
  </code></pre>