How to Store Multiple Elements per Key in an Array?

Problem:- How to Store Multiple Elements per Key in an Array? You want to associate multiple elements with a single Key.

Solution – Store Multiple Elements per Key in an Array

<?php
$fruits = array('red'=>array('strawberry', 'apple'), 'yellow'=> array('banana'));
print_r($fruits);
?>

How it Works?

We can do it with multi dimensional array system also we can use 2 or 4 dimensional array system.

Be the first to comment

Leave a Reply

Your email address will not be published.


*