开发者

How to decode and encode a multidimensional array in javascript and php

开发者 https://www.devze.com 2023-03-28 10:27 出处:网络
I need to encode a three dimensional array in javascript, send it to a php script and decode it there. The Problem is, javascript outputs array, just as one sequence of integers, you can\'t see the di

I need to encode a three dimensional array in javascript, send it to a php script and decode it there. The Problem is, javascript outputs array, just as one sequence of integers, you can't see the dimensions. I tried to convert the ar开发者_如何转开发ray to json but couldn't find figure out how to do it.

Thanks for your help


If you're making an ajax call, say using $.post, jQuery will automatically encode the data before it hits the PHP script you called. The size, scope, and complexity of the object doesn't matter.


Find a way to serialize the array - JSON or something similar. It provides a format to convert objects and arrays to plain text and vice versa.

0

精彩评论

暂无评论...
验证码 换一张
取 消