Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #19229

Re: JSON and PHP

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.php
Subject Re: JSON and PHP
Date Wed, 28 Dec 2022 19:00:28 +0100
Lines 44
Message-ID <k13ehqFliofU1@mid.individual.net> (permalink)
References <tog2vc$tnl$21@gallifrey.nk.ca>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace individual.net bNhDNwyCpgbXRuNItC81Wg2NdVGhVUW31dtXhjMMTEIxiLGWYY
Cancel-Lock sha1:IGisTf0mzL1jBDLzOe3AoO1+DU0=
Content-Language de-DE
In-Reply-To <tog2vc$tnl$21@gallifrey.nk.ca>
Xref csiph.com comp.lang.php:19229

Show key headers only | View raw


The Doctor, 2022-12-28 01:34:

> Trying to implement a JSON array in PHP
> 
> 
> Using
[...]

Can you please reduce such questions this to the relevant part?


[...]
> $myObj = [];
> if (isset($_POST["submit"])){
> (array_push($myObj,[
[...]

Why do you use array_push()? You can just build an array by assigning
values to it:

$myObj['key'] = $value;

[...]
> 'bill_first_name' =>[$_POST['bill_first_name']],

Why do you put an array here?

[$_POST['bill_first_name']] will resolve to a single element array:

'bill_first_name' => [ 'value' ];

Is this really what you want?

[...]
> 	  Just wonder how to supress repeats.

By using correct arrays and not that confusing mixture of values, empty
arrays and single element arrays.


-- 
Arno Welzel
https://arnowelzel.de

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JSON and PHP doctor@doctor.nl2k.ab.ca (The Doctor) - 2022-12-28 00:34 +0000
  Re: JSON and PHP "J.O. Aho" <user@example.net> - 2022-12-28 09:56 +0100
    Re: JSON and PHP doctor@doctor.nl2k.ab.ca (The Doctor) - 2022-12-28 14:42 +0000
      Re: JSON and PHP "J.O. Aho" <user@example.net> - 2022-12-28 22:09 +0100
        Re: JSON and PHP H H H H H H H H H H H H H H H H H H E <angel00000100000@icloud.com> - 2023-01-04 09:10 -0800
          Stop spamming (Was: JSON and PHP) "J.O. Aho" <user@example.net> - 2023-01-04 19:24 +0100
  Re: JSON and PHP Arno Welzel <usenet@arnowelzel.de> - 2022-12-28 19:00 +0100
  Re: JSON and PHP ThE sUn <angel00000100000@mail.ee> - 2022-12-28 21:28 -0800

csiph-web