Actually, I want to print the contents using sample code.
$html having all the HTML that I want to print, without rendering the view in the browser and without printing / displaying in the browser.
I am trying to find the same method as window.print(); . But you need it in PHP . I do not want to display all the HTML in the browser.
Is there any method or trick? Any suggestion can help me. Thanks.
My sample code is:
$arr = array('one','two','three','four','five'); $html = "<div style='background:red;color:black;'>"; foreach($arr as $value){ $html .= $value.'<br />'; } $html .= "</div>"; // print code to print $html content as same as JS window.print() works.
source share