Re: Replace punctuation in an associative array

"J.O. Aho" <[email protected]> Sun, 5 Mar 2023 00:41:30 +0100
Newsgroups comp.lang.php
Message-ID <[email protected]>
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