title: Sending struct through POST to php
body: <p>I have an iOS app that is written in Swift.</p>
  <p>The app has a cart, with items of a struct called <code>Order</code>, which has a <code>productName</code> inside it.</p>
  <p>When the order is finished, I am sending the data to a php file, so I can upload the data to my database.</p>
  <p>The problem is, when I send the variable <code>order</code> containing the users wishes products with the <code>Order</code> struct, and then I get the variable on the PHP page like so:</p>
  <pre><code>$order = $_POST[&quot;order&quot;];
  </code></pre>
  <p>When I <code>echo $order;</code> this is the response I get in the console of Xcode:</p>
  <pre><code>responseString = Optional(&quot;[MyAppName.Order]&quot;)
  </code></pre>
  <p>This is my Order struct:</p>
  <pre><code>struct Order: Codable {
     let productName: String
     let productQuantity: Int
     let productPrice: Int
  
     init(productName: String, productQuantity: Int, productPrice: Int) {
        self.productName = productName
        self.productQuantity = productQuantity
        self.productPrice = productPrice
     }
  
  }
  </code></pre>
  <p>I guess I need to change the struct so it can be read in a PHP file. <strong>What can I do to change the data in the struct so it will be readable for a PHP file?</strong></p>