title: How to break down tuple from Python to PHP
body: <p>I'm using HTTP post request from Codeigniter to python and return a tuple from MySQL to python</p>
  
  <p>Codeigniter controller:</p>
  
  <pre><code>$data['email'] = $this-&gt;input-&gt;post("email");
  $url = 'http://domain/path';
  $data = array('email' =&gt; $data['email']);
  
  // use key 'http' even if you send the request to https://...
  $options = array(
      'http' =&gt; array(
      'header'  =&gt; "Content-type: application/x-www-form-urlencoded\r\n",
      'method'  =&gt; 'POST',
      'content' =&gt; http_build_query($data),
      ),
  );
  $context  = stream_context_create($options);
  $result = file_get_contents($url, false, $context);
  
  var_dump($result);
  </code></pre>
  
  <p>Python code:</p>
  
  <pre><code>elif self.path=="/forgotpass":
      print "forgot password module"
      form = cgi.FieldStorage(
          fp=self.rfile, 
          headers=self.headers,
          environ={'REQUEST_METHOD':'POST',
                   'CONTENT_TYPE':self.headers['Content-Type'],
          })
      self.send_response(200)
      self.send_header('Content-type','text/html')
      self.send_header("Access-Control-Allow-Origin","http://domain")
      self.end_headers()
      #print form['email'].value
      email = str(form["email"].value)
      sql = "SELECT email_address, personal_id from personal_info where email_address='"+email+"'"
      result = validate(sql)
      print result
      #print email;
      self.wfile.write(result)
  
  
  def validate(sql):
      try:
          db = MySQLdb.connect("localhost","root","password","schema" )
          cnn = db.cursor()
          cnn.execute(sql)
          return cnn.fetchone()
  
          cnn.close()     
      except MySQLdb, e:
          print "Error validate function"
  </code></pre>
  
  <p>The display is, I think this is now a string format. </p>
  
  <pre><code>string(36) "('jerahmeel.acebuche@smsgt.com', 2L)"
  </code></pre>
  
  <p>In a simple Codeigniter connecting to a model. </p>
  
  <p>The result of an array from mysql is:</p>
  
  <p>array (column => value) etc etc..</p>
  
  <p>You could display that array using foreach and $item->data;</p>
  
  <p>But this result came from python which is a tuple and returning it to PHP is a different approach. </p>
  
  <p>How will I break this tuple in PHP? or should I break it on python and return it to PHP?</p>