you should really look into using json_encode(phpArr)
to format your data instead of building vars manually. it's faster, and the native feature are tested and patched, making them way more reliable when silly data works its way in, which is inevitable.
BROWSER STATS [% share]
(2013/10/31) IE7:0.5, IE8:8.6, IE9:5.3, IE10:12.3, FF:17.7, CH:41.8, SF:8.1, MOBILE:20.4