Thursday, September 8, 2011

Javascript Multi-Dimension Array to JSON Converter

The Problem
Lately ask by one of my programmer - How to pass a javascript multi-dimension array back to PHP? First thing strike in my mind, JSON.stringify! But after some quick reading and testing, found out that stringify does not support cyclic data structures.

Then brainstorming session begin. Why need to pass in multi-dimension array, why not this and why not that... And last, he just said "This is the way I want, can you make it happen or not?".

Thanks for his challenge, here by is the solution.