Posted by: Forca May 22 2017, 12:01 AM
I have an array of strings in a PHP script. Array has 10 keys. I wish to display contents of each array entry in html format by using embedded html.
Question: how to output a PHP array variable contents so that it can be styled by the applicable CSS styling sheet for the webpage?
I considered:
<code>
<?php if (condition): ?>
<p> Message to be displayed in html format since paragraph display governed by associated CSS file. </p>
<?php end-condition; ?>
</code>
So how to get the paragraph contents to be the output of the PHP array variable?
Thanks.
Posted by: Christian J May 22 2017, 09:03 AM
QUOTE(Forca @ May 22 2017, 07:01 AM)
I have an array of strings in a PHP script. Array has 10 keys. I wish to display contents of each array entry in html format by using embedded html.
You might iterate through the array, like this:
CODE
foreach ($arr as $value) {
echo "Value: $value<br />\n";
}
or this, if you want to display the $key names as well:
CODE
foreach ($arr as $key => $value) {
echo "Key: $key; Value: $value<br />\n";
}
(examples from http://php.net/manual/en/control-structures.foreach.php ). There are several ways to loop/iterate through arrays in PHP, and while the manual isn't very easy to understand there are lots of other sites on the web too.
QUOTE
Question: how to output a PHP array variable contents so that it can be styled by the applicable CSS styling sheet for the webpage?
Not sure I understood this, why not simply make the HTML and CSS selectors match the way you want?