Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: Replace punctuation in an associative array Date: Sun, 5 Mar 2023 00:41:30 +0100 Lines: 41 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net +QdiZGWBHEoG1uNzcCPIOA2Tjjy0weAlrH1qZf/yyhVbHDb83V Cancel-Lock: sha1:vodM7He7xpaI7MrdBOY7OrFhhG4= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US-large In-Reply-To: Xref: csiph.com comp.lang.php:19367 On 3/4/23 16:38, J.O. Aho wrote: > On 3/4/23 15:57, The Doctor wrote: >> a) Converting a page from a programmer that did not use classes > > Then you need to rewrite things, how many weeks hasn't you spent on > trying to get a proper json of the mess of arrays. Doing it right and > rewrite, I think you would have finished a month ago already. > > Take a look at the following code, test it too and you see the benefit > https://pastebin.com/yJC9DJWs > > If you rewrite things now, you will save time and efforts in the future, > specially if there comes changes to the API. Looking at your old posts, using the above code you would endup with something like this (not tested): https://pastebin.com/bF6bZseu this has same issues with unvalidated data, but at least now no one will get the items for free as the transaction value is calculated while adding items to the carts items array. if it's mainly changing how to load values from post, it's a short times convertion, if you store vallues in the session, then you need slightly more changes, specially if you need to access values, but should be quit simple to find out where with help of php lint function (php -l sourcodefile.php). Keep in mind nothin is a 100% solution for your issue as I haven't bothered really go into the API that is used but just a bit based on your posts in this group. And please, what ever you do, don't go with the str_replace, it's not the solution to your issue, it will just make things a lot harder to maintain. -- //Aho