Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI I am completing a search function searching by letter.

I want my letters to display as A | B | C | D | etc. See below code, however if i do

$letters="a | b |" etc it shows the | as a clickable link

Can someone help?

What I have tried:

$letters="abcdefghijklmnopqrstuvwxyz";
echo "<div class='bigMargin'>";
echo "<span class=\"bold\"><h4>Browse By Letter </h4><br></br></span>";
for ($i=0; $i<=35; $i++) {
   $letter=substr($letters,$i,1);
   echo "<a href='babyNameFinder.php?initial=$letter'>$letter</a> ";
}
echo "</div>";
Posted
Updated 5-Feb-18 2:31am

1 solution

You are creating links and therefore the text within the a tags will be shown as links. If you want to add separators, you have to print them outside the link tags:
PHP
$letters="abcdefghijklmnopqrstuvwxyz";
for ($i=0; $i<=35; $i++) {
    $letter=substr($letters,$i,1);
    if ($i)
        echo " | ";
    echo "<a href='babyNameFinder.php?initial=$letter'>$letter</a> ";
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900