1

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}

Manish Jesani
  • 1,339
  • 5
  • 20
  • 36
Christopher Shaw
  • 763
  • 6
  • 19

1 Answers1

2

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

Luc Hendriks
  • 2,473
  • 13
  • 18
  • Has the same effect as the base64, the string is too large. – Christopher Shaw Dec 16 '14 at 10:49
  • You can't really encode the string to be a lot less in size, unless you accept all unicode characters in you url (which you don't want for security reasons). You could also store the information in a session along with a random key and put that key in the url – Luc Hendriks Dec 16 '14 at 10:50