0
I want to put several classes in one div
, using Array
, how could I do it? I tried using the code below, but it didn’t work.
<?php
$minhas_classes = array(
'main-content' => 'main-content',
'post-count' => 'post-count',
'loop-style' => 'loop-style',
'has-image' => 'has-image',
);
?>
<div class="<?php echo $minhas_classes; ?>">
</div>
The last
,
(comma) to yourarray
is not necessary, other than that, I didn’t fully understand what you need. I could give some example?– Roberto de Campos
But to print a content of
array
would be so:echo $minhas_classes["post-count"];
, this way the second content would be printed.– Roberto de Campos
Can’t you print them all at once? Without having to repeat this: $my_classes["post-count"], $my_classes["main-content"]
– John Quimera
What’s the idea of having an associative array where the key is equal to the value?
– Woss
@Anderson Carlos Woss I get it.
– John Quimera