Mansi Raja
Mansi Raja

Reputation: 152

Create CSV file to the specific place on server in PHP with given HTML content

I have created CSV file using following code.

<?php
    $orders = '<table><tr class="dataTableRow"><td><b>Order ID</b></td><td>Ordered By</td><td>Email</td><td>Ordered On</td><td>Completed On</td><td>Line Items</td><td>Order Total</td>></table>';
    $text = "PHP";
    $list = array (
    array('111', '222', '333'),
    array($text),
    array($orders)
    );

    $fp = fopen('file.csv', 'w');
    foreach ($list as $fields) {
    fputcsv($fp, $fields);
    }
    fclose($fp);
?>

All data in CSV is properly displayed except the HTML content. I want to format contents inside CSV. I need some text in bold and some in italic.

Output of code

Is there any other way or any solution for this? Please help if somebody knows.

Upvotes: 0

Views: 111

Answers (1)

Kai Adelmann
Kai Adelmann

Reputation: 199

No chance, pal. CSV is plain text and you cannot format anything in plain text :-)

Upvotes: 1

Related Questions