Search code examples
phppreg-replacelowercase

PHP While with hyphen add and lowercase


Can anyone see what I am doing wrong with the Lowercase string?

The Preg_replace works but when I add the stringtolower it breaks with the message. " unexpected 'strtolower' (T_STRING), expecting ',' or ';'"

            <?php
            while($row10=mysql_fetch_array($result10))
            {
            echo "<a href=\"" . string strtolower (preg_replace('#[ -]+#', '-', $row10['english_navn'])); . ".php\"><div class=\"row\"><div class=\"large-3 columns\"><div class=\"b\"><br />" . $row10['chapter'] . "</div></div>";
            echo "<div class=\"large-9 columns\"><h2>" . $row10['english_navn'] .     "</h2></div></div></a>";
            }
            ?>

Solution

  • fixed your code for you. Next time i recommend using single quotes for a string so you dont have to use \" for html attributes

    <?php
    while($row10=mysql_fetch_array($result10))
    {
        echo "<a href=\"" . strtolower(preg_replace('#[ \-]+#', '-', $row10['english_navn'])) . ".php\"><div class=\"row\"><div class=\"large-3 columns\"><div class=\"b\"><br />" . $row10['chapter'] . "</div></div>";
        echo "<div class=\"large-9 columns\"><h2>" . $row10['english_navn'] . "</h2></div></div></a>";
    }
    ?>