How can CSS be utilized to format data output in PHP to display in small boxes or columns?
To format data output in PHP to display in small boxes or columns, you can use CSS to style the output. You can create a CSS class that defines the styling for the boxes or columns, and then apply that class to the HTML elements that display the data. This way, you can control the layout and appearance of the data output using CSS.
<?php
// PHP code to output data in small boxes or columns
$data = array("Item 1", "Item 2", "Item 3", "Item 4");
echo '<div class="box-container">';
foreach ($data as $item) {
echo '<div class="box">' . $item . '</div>';
}
echo '</div>';
?>
```
```css
/* CSS code to style the small boxes or columns */
.box-container {
display: flex;
flex-wrap: wrap;
}
.box {
width: 100px;
height: 100px;
background-color: lightblue;
margin: 10px;
padding: 10px;
border: 1px solid black;
}