Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert PHP array dump to CFML

Status
Not open for further replies.

imstillatwork

IS-IT--Management
Sep 26, 2001
1,605
US
I'm working with a database that is used by a PHP app. In several fields, PHP arrays are stored in a format sort of like what WDDX does, but not xml based. I need to convert that the something I can work with in CFML.

Here is an example:

Code:
a:6:{
      s:4:"name";
      s:12:"clinic_name1";
      s:5:"title";
      s:19:"Primary Clinic Name";
      s:4:"type";
      s:4:"text";
      s:11:"description";
      s:0:"";
      s:13:"validate_func";
      s:0:"";
      s:17:"additional_fields";
      a:9:{
        s:3:"sql";
        i:1;
        s:8:"sql_type";
        s:12:"VARCHAR(255)";
        s:4:"size";
        s:2:"20";
        s:7:"default";
        s:0:"";
        s:7:"options";
        a:0:{}s:4:"cols";
        s:2:"20";
        s:4:"rows";
        s:1:"5";
        s:14:"display_signup";
        s:1:"1";
        s:15:"display_profile";
        s:1:"1";
      }

You can see nested arrays, strings integers (a,s,i) and the number is the length of the value, or number of elements in the array. reading down the list of elements give you name,value,name,value,name,value as far as the application is concerned.

example:

Code:
a:9:{ (array)
        s:3:"sql"; (name)
        i:1; (value)
        s:8:"sql_type"; (name)
        s:12:"VARCHAR(255)"; (value)


Has anyone ever written or seen a UDF that will convert this sort of thing into a CFML array (nested arrays)

I am simply not good enough with regex to start breaking it down. I might have to learn though.

I know a few things:
1) It will have to be recursive

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top