What are some common methods for adding icons or symbols to bookmarks in PHP?

When creating bookmarks in PHP, it can be useful to add icons or symbols to visually represent different categories or types of bookmarks. One common method to achieve this is by using a CSS class that includes a background image or icon font. By adding this class to the bookmark link, you can easily style it with the desired icon.

<?php
// Define an array with bookmark categories and their corresponding icons
$bookmarkCategories = [
    'programming' => 'fa fa-code',
    'design' => 'fa fa-paint-brush',
    'recipes' => 'fa fa-cutlery'
];

// Loop through bookmarks and add icons based on category
foreach ($bookmarks as $bookmark) {
    $category = $bookmark['category'];
    $iconClass = isset($bookmarkCategories[$category]) ? $bookmarkCategories[$category] : 'fa fa-bookmark';

    echo '<a href="' . $bookmark['url'] . '" class="bookmark-link"><i class="' . $iconClass . '"></i>' . $bookmark['title'] . '</a>';
}
?>