store data into a text file using php?

前端 未结 6 1362
有刺的猬
有刺的猬 2021-01-13 14:46

i am trying to store data in a text file, something like an array into a text file using php instead of storing into mysql database.

for example here are the data to

6条回答
  •  我在风中等你
    2021-01-13 15:20

    Storing:
    1. Use serialize() to serialize your array into a string
    2. Write that string to text file using file_put_contents()

    Reading:
    1. Use file_get_contents to read text file
    2. Use unserialize() to unserialize previously serialized array

    serialize()/unserialize() can be replaced by json_encode()/json_decode()

提交回复
热议问题