Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: Stripping a JSON of extra characters in PHP Date: Mon, 6 Feb 2023 20:40:47 +0100 Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net 0VuHJdgBjxB9Yjp4EvwzwQHdUGl2RLxj9akMbuWG6fdzig0h1W Cancel-Lock: sha1:gvRoyRusAod47IUVDXqZxOUbdzU= Content-Language: de-DE In-Reply-To: Xref: csiph.com comp.lang.php:19304 The Doctor, 2023-02-06 16:28: [...] > The cart is being derived from a previous form being passed into PHP! [...] > $arr=array( > 'store_id' => "store3", > 'api_token' => "yesguy", > 'checkout_id' => "chktGLFZQtore3", > 'txn_total' => $_POST['charge_total'], > 'environment' => "qa", > 'action' => "preload", > 'cart' => array( > (foreach ($_POST['quantity'] as $key => $value) { Well - this will result in an array in the JSON named "cart". > $cart['items'][] =array( And this will also become an array named "items" inside "cart". So if you don't want "cart" to be an array in the JSON, then don't create it this way. Learn how to read JSON and that the "punctuation" are not just characters but have a specific meaning. In this case you created an array and the JSON will have an array as well - indicated by "[" and "]". -- Arno Welzel https://arnowelzel.de