Good morning,
i have a section in a php page as per code:

<div class="container section" id="afterHeader">
                                <div class="row">                                   
                                        <div class="tabs movies">
                                        <a class="style1">1^ WEEK</a>
                                                <ul>                                   
                                                <li><a href="#thu">GIO</a></li>
                                                <li><a href="#fri">VEN</a></li>
                                                <li><a href="#sat">SAB</a></li>
                                                <li><a href="#sun">DOM</a></li>
                                                <li><a href="#mon">LUN</a></li>
                                                <li><a href="#tue">MAR</a></li>
                                                <li><a href="#wed">MER</a></li>
                                                </ul

I would need to replace the part <ul> </ul> part with this other code:

<?php
function myTab()
{
    echo str_repeat('&nbsp;', 3);
}

function templateDay($start, $end)
{
    $dayOfWeek = ['LUN', 'MAR', 'MER', 'GIO', 'VEN', 'SAB', 'DOM'];   
    $toDay = date('N') - 1;

    for ($i = $start; $i < $end; $i++) {
        echo $dayOfWeek[$toDay] === $dayOfWeek[$i] ? "<a style='color:red'>" . 'OGGI' . '</a>' . myTab() : "" . $dayOfWeek[$i] . '</a>' . myTab();
    }
}
templateDay(3, 7);
templateDay(0, 3);
?>

Can anyone help me?
Thanks

Recommended Answers

Like this?

<div class="container section" id="afterHeader">
        <div class="row">                                   
                    <div class="tabs movies">
                                <a class="style1">1^ WEEK</a>
                                        <ul>                                   

                                                <?php
                                                function myTab()
                                                {
                                                    echo str_repeat('&nbsp;', 3);
                                                }

                                                function templateDay($start, $end)
                                                {
                                                    $dayOfWeek = ['LUN', 'MAR', 'MER', 'GIO', 'VEN', 'SAB', 'DOM'];   
                                                    $toDay = date('N') - 1;

                                                    for ($i = $start; $i < …
Jump to Post

All 2 Replies

Like this?

<div class="container section" id="afterHeader">
        <div class="row">                                   
                    <div class="tabs movies">
                                <a class="style1">1^ WEEK</a>
                                        <ul>                                   

                                                <?php
                                                function myTab()
                                                {
                                                    echo str_repeat('&nbsp;', 3);
                                                }

                                                function templateDay($start, $end)
                                                {
                                                    $dayOfWeek = ['LUN', 'MAR', 'MER', 'GIO', 'VEN', 'SAB', 'DOM'];   
                                                    $toDay = date('N') - 1;

                                                    for ($i = $start; $i < $end; $i++) {
                                                        echo '<li>';
                                                        echo $dayOfWeek[$toDay] === $dayOfWeek[$i] ? "<a style='color:red'>" . 'OGGI' . '</a>' . myTab() : "" . $dayOfWeek[$i] . '</a>' . myTab();
                                                        echo '</li>';
                                                    }
                                                }
                                                templateDay(3, 7);
                                                templateDay(0, 3);
                                                ?>


                                        </ul>

Thanks Dani for your reply. I forgot to mention that every day is linked to another page. this complete code

                                               <li><a href="#thu">GIO</a></li>
                                                <li><a href="#fri">VEN</a></li>
                                                <li><a href="#sat">SAB</a></li>
                                                <li><a href="#sun">DOM</a></li>
                                                <li><a href="#mon">LUN</a></li>
                                                <li><a href="#tue">MAR</a></li>
                                                <li><a href="#wed">MER</a></li>
                                                </ul>
                            <div id="mon">
                                <?php mostralunedi();  ?>
                        </div>
                            <div id="tue">
                                <?php mostramartedi();  ?>
                        </div>
                            <div id="wed">
                                <?php mostramercoledi();  ?>
                        </div>
                            <div id="thu">
                                <?php mostragiovedi();  ?>
                        </div>
                            <div id="fri">
                                <?php mostravenerdi();  ?>
                        </div>
                            <div id="sat">
                                <?php mostrasabato();  ?>
                        </div>
                            <div id="sun">
                                <?php mostradomenica();  ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.