$data = array('name' => 'John', 'age' => 30); $jsonString = json_encode($data); file_put_contents('data.json', $jsonString);
$csvData = array( array('name', 'age', 'email'), array('John Doe', 30, 'john@example.com'), array('Jane Doe', 25, 'jane@example.com') ); $fp = fopen('data.csv', 'w'); foreach ($csvData as $fields) { fputcsv($fp, $fields); } fclose($fp);
$xmlData = new SimpleXMLElement('Package Library: The PHP Module Save is a built-in module and doesn't require any external package or library.'); $student = $xmlData->addChild('student'); $student->addChild('name', 'John Doe'); $student->addChild('age', 30); $student->addChild('email', 'john@example.com'); $xmlData->asXML('data.xml');