How do I store an array in a file to access as an array later with PHP?

前端 未结 8 1346
粉色の甜心
粉色の甜心 2020-12-02 14:17

I just want to quickly store an array which I get from a remote API, so that i can mess around with it on a local host.

So:

  1. I currently have an array.<
8条回答
  •  自闭症患者
    2020-12-02 14:53

    If you don't need the dump file to be human-readable, you can just serialize() the array.

    storing:

    file_put_contents('yourfile.bin', serialize($array));
    

    retrieving:

    $array = unserialize(file_get_contents('yourfile.bin'));
    

提交回复
热议问题