PHP: Object to URL Data

June 3rd, 2008 · No Comments

This is a simple, but very handy function when working with PHP and Flash.  This will turn an object into a string of URL data – this is very helpful converting a mySQL object from mysql_fetch_object to Flash variables.

  1. function object2URLData($obj)
  2. {
  3.      $data = "";
  4.      foreach($obj as $key=>$prop)
  5.      {
  6.           if($data != ""){ $data .= "&"; }
  7.                $data .= "$key=$prop";
  8.      }
  9.      return $data;
  10. }

Tags: Flash · PHP