I know this is kind of very simple and has many answers but i didn't got my ans so posting this:
I want to create a file and write data to that file.
I have tried this :
$data = array
(
'SipUserName' =>'',
'SipAuthName' =>'' ,
'DisplayName' =>'' ,
'Password' => '',
'Domain' => '',
'Proxy' => '',
'Port' => '',
'ServerMode' => ''
);
$file = fopen('./uploads/text.ini','w');
// Open the file to get existing content
$current = file_get_contents('./uploads/text.ini');
// Append a new person to the file
$current .= implode('', $data);
// Write the contents back to the file
file_put_contents('./uploads/text.ini', $current);
2nd Option
$this->load->helper('file');
$data = array
(
'SipUserName' =>'',
'SipAuthName' =>'' ,
'DisplayName' =>'' ,
'Password' => '',
'Domain' => '',
'Proxy' => '',
'Port' => '',
'ServerMode' => ''
);
$fp = fopen('./uploads/test.ini', 'w');
fwrite($fp, implode("", $data));
fclose($fp);
expected output
[INIDetails]
SipUserName =
SipAuthName =
DisplayName =
Password =
Domain =
Proxy =
Port =
ServerMode=Automatic
But doesn't work.
I want to write this array as sting to my file.
Also i want to set a prefix to each new file that i create how do i do this?