Re: Replace punctuation in an associative array

The Doctor <[email protected]> Sat, 4 Mar 2023 23:58:35 -0000 (UTC)
Newsgroups comp.lang.php
Organization NetKnow News
Message-ID <[email protected]>
J.O. Aho <[email protected]> wrote:
: 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.


Actually the class approach works better.

Too bad Google does not pick that up
in their searches for JSON>

-- 
Member - Liberal International This is [email protected] Ici [email protected]
Yahweh, King & country!Never Satan President Republic!Beware AntiChrist rising!
Look at Psalms 14 and 53 on Atheism https://www.empire.kred/ROOTNK?t=94a1f39b 
We cannot defy gravity without paying a price. -unknown Beware https://mindspring.com