Print HTML tags with PHP

1

I have this code:

$html = array(
'<div id="grupo"><span>5</span><p>Invitacion de boda calendario 1</p><p>Cantidad : 1</p></div>',
'<div id="grupo"><span>6</span><p>Invitacion de boda calendario 2</p><p>Cantidad : 1</p></div>',
'<div id="grupo"><span>7</span><p>Invitacion de boda calendario 3</p><p>Cantidad : 1</p></div>',
);

When printing I get all the labels, how to make me print the values of the variable $html in HTML format

    
asked by c3media 19.05.2017 в 21:31
source

3 answers

0

To make it only show you the content and not the tags, you have to use the php strip_tags method. Which removes the tags from html and leaves only the content. Here is an example:

<?php      
   $html = array(
            '<div id="grupo"><span>5 </span><p>Invitacion de boda calendario 1</p><p> Cantidad : 1</p></div>',
            '<div id="grupo"><span>6 </span><p>Invitacion de boda calendario 2</p><p> Cantidad : 1</p></div>',
            '<div id="grupo"><span>7 </span><p>Invitacion de boda calendario 3</p><p> Cantidad : 1</p></div>',
            );

    $printer='EPSON L355 Series';
    $enlace=printer_open($printer);

    for($i=0; $i < count($html); $i++){
         printer_write($enlace, strip_tags($html[$i]));
    }
    printer_close($enlace);
     ?>
    
answered by 19.05.2017 / 21:49
source
0

An easy way to print arrays is with a cycle.

Either with For , While , or Foreach .

I'll give you an example with Foreach:

<?php
$array = array(1, 2, 3, 4);
foreach ($array as &$valor) {
    echo $valor;
}
?>

I leave you the PHP documentation to print with Foreach

    
answered by 19.05.2017 в 21:54
0

If you want only the values, the best option is to use strip_tags to remove the HTML tags, but if you want to debug seeing the output you can use var_dump ();

var_dump($html);
    
answered by 20.05.2017 в 18:28