(I want it like this) For Example. I dont know how to create 2d arrays where i can add section title and show several packages after that i need to show logo design heading with logo design packages and etc..
<section id="packages" data-aos-delay="0" data-aos-duration="0" data-aos="fade" class="page-section">
<div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="display-4" data-aos="zoom-out-up">Packages</h1>
</div>
<div class="container">
<div class="row justify-content-center mb-3">
<?php foreach ($temp_packages as $package) : ?>
<?php
$title = $package['title'];
$package_price = get_post_meta($package['id'], '_package_price', true);
$package_subtitle = get_post_meta($package['id'], '_package_subtitle', true);
$package_attributes = get_post_meta($package['id'], "_package_attributes", true);
?>
<div class="col-lg-4 col-md-4 col-sm-12">
<div class="card mb-4 box-shadow">
<div class="card-header">
<h2 class="my-3">$ <?php echo $package_price; ?></h2>
<h4 class="my-1"><?php echo $title; ?></h4>
<h6 class="mb-2"><?php echo $package_subtitle; ?></h6>
</div>
<div class="card-body">
<ul class="list-unstyled">
<?php if (gettype($package_attributes) == 'array') : ?>
<?php foreach ($package_attributes as $attribute) : ?>
<li>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
<a href="#contactUs" type="button" class="btn btn-lg btn-block btn-primary">Enquire</a>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
<?php endif; ?>
2
Answers
Creating 2D arrays in PHP is actually very easy:
Is that what you were looking for?
I just created an Array PHP: Arrays with all the content you need. Here is my array with one example entry:
The content of
$temp_packages
will probaly be stored in a database and be fetched from there.After that, you can use your code to generate your section. I changed a bit, so it works for me: