note 97768 added to function.json-decode

From: Date: Fri, 07 May 2010 03:47:05 +0000
Subject: note 97768 added to function.json-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-169036@lists.php.net to get a copy of this message
Example: URL: foo.php?bar=["one", "two", "three"] Problem { Code: <?PHP print_r(json_decode($_GET['bar'])); ?> Output: Code: <?PHP echo $_GET['bar']; ?> Output: [\"one\",\"two\",\"three\"] } Solution{ Code: <?PHP echo stripslashes($_GET['bar']); ?> Output: ["one","two","three"] Code: <?PHP print_r(json_decode(stripslashes($_GET['bar']))); ?> Output: Array ( [0] => one [1] => two [2] => three ) } Explanation: Make sure if you are getting your data in a form that php slashes out perform stripslashes on your var. Warning: Be sure you know where your data is coming from and what type of formatting is being used so you can read it properly. Warning 2: Using stripslashes on strings that are not slashed may have undesirable effects. Mahalo, Ariel P.s. Hope this helps feel free to email me for help... (my first name at ubersoftech dot com) ---- Server IP: 69.147.83.197 Probable Submitter: 76.93.205.41 ---- Manual Page -- http://www.php.net/manual/en/function.json-decode.php Edit -- https://master.php.net/note/edit/97768 Del: integrated -- https://master.php.net/note/delete/97768/integrated Del: useless -- https://master.php.net/note/delete/97768/useless Del: bad code -- https://master.php.net/note/delete/97768/bad+code Del: spam -- https://master.php.net/note/delete/97768/spam Del: non-english -- https://master.php.net/note/delete/97768/non-english Del: in docs -- https://master.php.net/note/delete/97768/in+docs Del: other reasons-- https://master.php.net/note/delete/97768 Reject -- https://master.php.net/note/reject/97768 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169036) next »