I need to store some data in a JSON file. I know how to use json_encode but I can't find any information on how to write the encoded data into an external file. Here's a pice of code that prints out the encoded data, but how can I write the data in a separate JSON file?
<?php
$array1 = array('key1' => "data1",
'key2' => "data2",
'key3' => "data3",
'key4' => "data4",
'key5' => "data5");
echo json_encode($array1);
?>