I'm using console java tool Zxing to decode qr codes from images. I call it from php and it works fine but now I'm stuck with parsing the response that it gives:
file:/home/users/public_html/playground/qrcode/images/new.png (format: QR_CODE, type: TEXT):
Raw result:
{"uniqueid":44819,date:131232211}
Parsed result:
{"uniqueid":44819,date:131232211}
Found 4 result points.
Point 0: (22.5,88.5)
Point 1: (22.5,22.5)
Point 2: (88.5,22.5)
Point 3: (79.5,79.5)
What I need is to get {"uniqueid":44819,date:131232211} portion. I tried something like:
$response=explode(" ",$response);
$response=preg_replace(array("/Parsed/","/result:/"),array("",""),explode(" ",$response[5]));
$response=$a[0];
And also tried substring
with strpos
. But it is only suitable for non-spaced strings. So I want an universal solution for that.
Also I dont really know if there is any way to make zxing return response in another more reliable format so I can simply avoid these php manipulations.
Some cool regular expression to cut this out? Maybe. But I'm not such good at it.
Ideas?