简体   繁体   中英

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

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 array 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM