Encoding an array for url in PHP

≯℡__Kan透↙ 提交于 2019-12-04 05:08:19

问题


I have been working on some QR codes, I need to pass an array to the QR with the data but it needs encoding. The data itself is a json_array which is used to generate a PDF.

If I use base64 encoding the QR code is stupidly large, and when using ascii85 it breaks the QR.

Can you let me know of any encoding praticies which would work in the url, the shorted the coding the betetr. qr_generator.php?data={encoded_json_array}


回答1:


You can try this:

urlencode($string);

It encodes a string to be appended as an url parameter. So if you have an array, try:

urlencode(json_encode($array);



来源:https://stackoverflow.com/questions/27502410/encoding-an-array-for-url-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!