// Opening and reading a CSV file $csvFile = fopen('file.csv', 'r'); while (($data = fgetcsv($csvFile, 0, ',')) !== false) { // Do something with the data } fclose($csvFile); // Writing to a CSV file $csvFile = fopen('file.csv', 'w'); $data = array('John', 'Doe', '25'); fputcsv($csvFile, $data); fclose($csvFile);
// Generating a PDF using the TCPDF library require_once('tcpdf/tcpdf.php'); $pdf = new TCPDF(); $pdf->AddPage(); $pdf->SetFont('Times', '', 12); $pdf->Write(5, 'Hello, world!'); $pdf->Output('file.pdf', 'I');
// Parsing an XML file using the SimpleXML library $xml = simplexml_load_file('file.xml'); foreach ($xml->person as $person) { // Do something with the person data } // Creating and writing to an XML file using the DOM library $doc = new DOMDocument(); $root = $doc->createElement('root'); $doc->appendChild($root); $person = $doc->createElement('person'); $person->setAttribute('id', '1'); $root->appendChild($person); $name = $doc->createElement('name', 'John Doe'); $person->appendChild($name); $doc->save('file.xml');Package library: PHP includes built-in support for parsing and creating XML using various extensions such as SimpleXML, DOM, XMLReader, and XMLWriter. However, there are also third-party libraries that provide additional functionality such as XMLRPC, which is used for remote procedure calls using XML.