-1

我需要做一个简单的php字母导航

这是html

    `<div id="meet_search_bar">
    <h4>FIND AN AGENT:</h4>
    <p id="alpha_button">BY ALPHA</p>
    <p id="language_button">BY LANGUAGES SPOKEN</p>
    <p id="specialty_button">BY SPECIALTIES</p>
    <input type="text" placeholder="first name..." id="agent_first"/> 
    <input type="text" placeholder="last name..." id="agent_last"/>
    <input type="submit" value="Go!"/>
</div>
<div id="agent_search_criteria" style="display:none;">
    <div id="alpha_search" style="display:none;">
    <h2 style="color:#cc0000">BY NAME:</h2>
        <h3 style="background-color:#cc0000;border-radius:2px;padding:4px 10px 4px 10px;color:white;">A</h3>
        <h3>B</h3>
        <h3>C</h3>
        <h3>D</h3>
        <h3>E</h3>
        <h3>F</h3>
        <h3>G</h3>
        <h3>H</h3>
        <h3>I</h3>
        <h3>J</h3>
        <h3>K</h3>
        <h3>L</h3>
        <h3>M</h3>
        <h3>N</h3>
        <h3>O</h3>
        <h3>P</h3>
        <h3>Q</h3>
        <h3>R</h3>
        <h3>S</h3>
        <h3>T</h3>
        <h3>U</h3>
        <h3>W</h3>
        <h3>X</h3>
        <h3>Y</h3>
        <h3>Z</h3>
        <br/><br/>
        <h4>anna</h4>
        <h4>Annemarie </h4>
        <h4>Agent Name...</h4>`

我需要帮助构建 php 我可能一年没做过 php 所以我需要一些帮助

4

1 回答 1

4

您可以使用range. 这些可以是数字或字母。

// Get all the alphabet letters as an array!
$alphabetLower = range('a', 'z'); // All letters a-z!
$alphabetUpper = range('A', 'Z'); // All letters A-Z!

// Next loop over them (lower in this case) and output them!
foreach($alphabetLower as $letter)
{
    // Outputs <h3>a</h3>
    echo "<h3>".$letter."</h3>";
}
于 2013-07-23T15:06:04.797 回答