在PHP中为url编码数组 [英] Encoding an array for url in PHP

查看:229
本文介绍了在PHP中为url编码数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用一些QR码,我需要将数据传递给QR数据,但需要编码。数据本身是用于生成PDF的 json_array



如果我使用 base64 编码QR码是愚蠢的,当使用 ascii85 它会打破QR。


$ b $你可以让我知道在url中工作的任何编码praticies,编码 betetr的短路。你可以试试这个:



urlencode($ string);



它将一个字符串作为url参数附加。所以如果你有一个数组,请尝试:



urlencode(json_encode($ array);


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}

解决方案

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);

这篇关于在PHP中为url编码数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆