Answers for "write file using file put content in php"

PHP
1

write in a file using php

<?php
$myfile = fopen("file_name.txt", "w") or die("Unable to open file!");
$txt = "Hello worldn";
fwrite($myfile, $txt);
$txt = " Php.n";
fwrite($myfile, $txt);
fclose($myfile);
?>
Posted by: Guest on June-05-2020
1

php file put content

<?php
$data = ["[email protected]" => ["more" => ["yes" => "More"]]];

$inp = file_get_contents('results.json');
$tempArray = json_decode($inp);
array_push($tempArray, $data);
$jsonData = json_encode($tempArray);
file_put_contents('results.json', $jsonData);
Posted by: Guest on January-13-2021

Browse Popular Code Answers by Language