title: slack, php and json - Valid Markup for iterating app selections
body: <p>I've been trying to create a slack app which takes the basic information of the name and sku of the product and places it within a select box that appears in slack. Unfortunately my code to populate the valid json is going wrong somewhere when i try to itterate using a loop. </p>
  
  <p><strong>Valid Json is here:</strong></p>
  
  <pre><code>{
      "text": "Great! You want to find something!",
      "attachments": [
          {
              "text": "Please type what you want to find",
              "fallback": "Sorry! Cant do that at the moment!",
              "callback_id": "cg_selectproduct",
              "color": "#3AA3E3",
              "attachment_type": "default",
  
              "actions": [
  
                  {
                      "name": "cg_choice",
                      "text": "Find Product",
                      "type": "select",
                      "options": [
                          {
                                  "text": "option1",
                                  "value": "option1"
                          },
  
                          {
                                  "text": "option2",
                                  "value": "option2"
                          },
                          {
                                  "text": "option3",
                                  "value": "option3"
                          }]
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>This works perfectly fine without the iteration. I have no issues if i tell the app to go here. It displays all options correctly.</p>
  
  <p><strong>Invalid PHP</strong></p>
  
  <pre><code>$check = ($dbh-&gt;prepare("SELECT * FROM product_list WHERE FAMILY='PARENT'"));
  $check-&gt;execute();
  $row = $check-&gt;fetchAll();
  // execute a pdo search to find all product parents
  
  $jsonInput = "";
  foreach($row as $rows){
  $jsonInput .= '"text"=&gt;"' . $rows['PRODUCT_NAME'] . '", "value" =&gt; "' . $rows['SKU'] . '",';
  }
  $jsonInput = rtrim($jsonInput, ',');
  //Create an iterative string which will contain the product names and skus, removing the comma at the end.
  
  header('Content-Type: application/json');
  //Set the content type to json
  
  
  $optionSelect = array(
      "text" =&gt; "Great! You want to find something!",
      "attachments" =&gt;array(
              "text" =&gt; "Please type what you want to find",
              "fallback" =&gt; "Sorry! Cant do that at the moment!",
              "callback_id" =&gt; "cg_selectproduct",
              "color"=&gt; "#3AA3E3",
              "attachment_type" =&gt; "default",
  
              "actions" =&gt; array(
                      "name" =&gt; "cg_choice",
                      "text" =&gt; "Find Product",
                      "type" =&gt; "select",
                      "options" =&gt; array($jsonInput)
                          )
  
             )
  
      );
  //Create and itterate the options for the selection so it's populated
  
  print_r(json_encode($optionSelect));
  //print to show json
  </code></pre>
  
  <p>I'm not 100% sure where i'm going wrong with this. Maybe i'm thinking about a minor part a little too much. Can anyone here help me with where i'm going wrong? </p>