Results 1 to 4 of 4

Thread: as posted elseware

  1. #1
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default as posted elseware

    As posted elseware by james 348 I believe:

    Code:
    <?php 
    $my_array = array('home', 'member', 'join', 'login', 'news'); 
    $ret=implode(' | ',$my_array);
    echo $ret; 
    ?>
    How would I assign urls to the links.

    (please keep in mind I am a newbie with php...)

    Bud

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Do you mean...

    PHP Code:
    <?php 
    $my_array 
    = array('<a href="index.php">home</a>''<a href="user.php">member</a>''<a href="join.php">join</a>''<a href="login.php">login</a>''<a href="news.php">news</a>'); 
    $ret=implode(' | ',$my_array);
    echo 
    $ret
    ?>
    If not please be more specific.
    Corrections to my coding/thoughts welcome.

  3. The Following User Says Thank You to bluewalrus For This Useful Post:

    ajfmrf (08-30-2011)

  4. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Or perhaps a bit confusing, but space/keystroke saving:

    PHP Code:
    <?php
    $my_array 
    = array('index.php">home''user.php">member''join.php">join''login.php">login''news.php">news');
    $ret '<a href="' implode('</a> | <a href="'$my_array) . '</a>';
    echo 
    $ret;
    ?>
    If you used the text as keys and the href values as their values, you do foreach on it. If I work that out, I'll add it.

    Got it:

    PHP Code:
    <?php
    $my_array 
    = array(
        
    'home' => 'index.php',
        
    'member' => 'user.php',
        
    'join' => 'join.php',
        
    'login' => 'login.php',
        
    'news' => 'news.php'
    );
    $c count($my_array);
    foreach(
    $my_array as $key => $val){
        echo 
    "<a href='$val'>$key</a>";
        if(--
    $c){echo ' | ';}
    }
    ?>
    Last edited by jscheuer1; 08-30-2011 at 08:13 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ajfmrf (08-30-2011)

  6. #4
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default well...

    I was getting close to what you both have.Not there yet but inching there.

    Thanks to both of you .

    Bud

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •