How to write the array (k1 & amp; gt; v1, k2 & amp; gt; v2) into a file. The content in the file is basically consistent with the following format: array (k1 & amp; gt; v1, k2 & amp; gt; v2) do not write a line with me. Is there a quick way? How to write the array (k1 => v1, k2 => v2) into a file. The content in the file is basically the same as the following format:
Array (
K1 => v1,
K2 => v2
)
Don't talk to me about writing a line. Is there a quick way?
Reply content:
How to write the array (k1 => v1, k2 => v2) into a file. The content in the file is basically the same as the following format:
Array (
K1 => v1,
K2 => v2
)
Don't talk to me about writing a line. Is there a quick way?
File_put_contents('result.txt ', var_export ($ categories, true ));
Okay, I have done it myself ..
In this case, file_put_contents('result.txt ', print_r ($ categories, true); or error_log (print_r ($ categories, true), 3, 'result.txt'); or.
Var_export is not in this format ~~~
Print_r should be used
File_put_contents('filename.txt ', print_r (array ($ k1 => $ v1, $ k2 => $ v2 ));