K
K
keslo2014-09-16 12:19:02
linux
keslo, 2014-09-16 12:19:02

How to format an entry as an associative array in JSON format in PHP?

Good afternoon, ladies and gentlemen.
- I create a named array using array()
- I encode it using json_encode - I
write it to a local file : ... then, according to the above points, the new file after appending in JSON format will be like this:
[ {первая запись} {вторая запись} ]
{ "test" : "test" }

{ "test" : "test", "0" : { первая запись }, "1" : { вторая запись } }

Question: how to make it so that new array() is written to a new empty file already in the form of JSON in this form:
{"0" : { первая запись } , "1" : { вторая запись } }

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Danil Biryukov-Romanov, 2016-09-07
@urtow

ln /files/by-group/group1 /files/user/user1/group1
If the /files/user/user1/group1 directory already exists, save all the data from it, delete it, and then run the command.

Y
youngdref, 2016-09-07
@youngdref

Not an expert, but:
Mount /files/by-group/group1 to /files/user/user1/group1
use symlin on the folder /files/user/user1/group1

S
SergeySL, 2016-09-07
@SergeySL

Move or delete all data from /files/user/user1/group1 then:
rm -rf /files/user/user1/group1 && ln -s /files/by-group/group1 /files/user/user1/group1

V
Vladislav, 2014-09-16
@keslo

json_encode ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question