Writing Array to File in php And getting the data

后端 未结 4 990
忘了有多久
忘了有多久 2021-02-05 21:38

I have An array which looks like following after using print_r

Array ( [0] => Array ( [0] => piklu [name] => piklu ) [1] => Array ( [0]          


        
4条回答
  •  你的背包
    2021-02-05 22:11

    file_put_contents writes a string to a file, not an array. http://php.net/manual/en/function.file-put-contents.php

    If you'd like to write what you see there in that print_r to a file, you can try this:

    ob_start();
    print_r($myarray);
    $output = ob_get_clean();
    file_put_contents("myfile.txt",$output);
    

提交回复
热议问题