Answer the question
In order to leave comments, you need to log in
How to output a two dimensional PHP array?
Greetings. Tell me how to display the [slider] array in such a two-dimensional construction:
Array
(
[slider] =>
images/about2.png
images/img3.png
images/news.png
)
Tried like this, it doesn't work
for ($i = 0; $i < count($additionalFields); $i++) {
for ($k = 0; $k < count($additionalFields[$i]); $k++) {
echo $additionalFields[$i][$k];
}
}
Answer the question
In order to leave comments, you need to log in
foreach($additionalFields as $slides) {
foreach($slides as $slide) {
echo $slide;
}
}
<div class=“slider”>
<?php foreach($additionalFields as $slides) :
foreach($slides as $slide) : ?>
<div class=“slide”>
<img src=“<?= $slide; ?>”/>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
if (isset($additionalFields[‘slider’])) {
foreach($additionalFields[‘slider’] as $slide) {
echo $slide;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question