I would like to know if it is possible to categorize data in groups when echoing it .
For example if I have a table of different phones and separate them by brand, i.e. Apple, Samsung etc, and I want the data to be displayed with a header of the brand of phone and under would have the phone type.
Apple
iphone 4
iphone 4s
iphone 5
Samsung
Galaxy Note 2
Galaxy S4
<div id="wrap">
    <table>
        <thead>
            <tr>
                <th><?php echo phones['brand']; ?></th>
                <th>Price</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach($phones as $phone): ?>
                <tr>
                    <td><?php echo $phone['name']); ?>
                        <br>
                    <ul>
                        <li><?php echo $phone['price']); ?></li>
                    </ul>
                    </td>
                    <td>$<?php echo $phone['released']); ?></td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>
This is what I have so far, sorry for the wait.
 
     
     
     
    