Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:07:13+00:00 2026-05-25T19:07:13+00:00

My array displays properly but I would like for the link inside to display

  • 0

My array displays properly but I would like for the link inside to display the current value of the array.

Here is my code:

foreach( $persons as $pid => $p)
{
    echo '<a href="?tag=">' . implode( '</a>, <a href="?tag=">', $tags[ $p['id'] ])  . '</a>';
    echo '<br /><br />';
}

This is what I want to display:

<a href="?tag=tag1">tag1</a>, <a href="?tag=tag2">tag2</a>

UPDATE
I got the answer elsewhere. Turns out it was pretty simple. Going to accept answer that’s helped me improve on my code.

$tags_arr = $tags[$p['id']];    
    foreach($tags_arr as $v){
  $out[] = "<a href='?tag=$v'>$v</a>";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:07:14+00:00Added an answer on May 25, 2026 at 7:07 pm

    I’m assuming $tags is an array itself, and you are attempting to write out each tag for each $p['id']. If I have it correct, don’t use implode() for this. Instead use two foreach loops.

    foreach ($persons as $pid => $p) {
      foreach ($tags as $t) {
        echo "<a href='?tag={$t[$p['id']]}'>{$t[$p['id']]}</a>\n";
      }
    }
    

    UPDATE

    I see some problems here:

        $persons[$row['id']]['title'] = $row['title'];
        $persons[$row['id']]['height'] = $row['height'];
        $persons[ $row['id'] ] = array( 'id' => $row['id'], 'tag' => $row['tag']);
    

    Above, you set the title and height array keys to $persons[$row['id']]. Following that though, you overwrite the whole $persons[$row['id']] with a new array(). Instead since you’re keeping the same array keys you can simply use:

    $persons[$row['id']] = $row;
    

    Now where I believe the most serious problem is:

    $tags[ $row['id'] ][] = $row['tag'];
    

    By using the [] notation, you are appending $row['tag'] onto the $tags[ $row['id'] as an array element rather than setting its value to the tag. That’s the reason you’re getting Array(1) in place of the tag value. Instead use:

    $tags[$row['id']] = $row['tag'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The below code works properly, but it is hard coded. I would like to
I would like to display the content of an array in a Googlemap bubble.
I am having trouble getting the below array to display properly in a smarty
I'm trying to create an array to display the last 5 products a customer
I am looking to display an array from 128 to 512 bytes in size
I'm trying to display an array of files in order of date (last modified).
I am required to display a two dimensional numpy.array of int16 at 20fps or
I have a an array of observable collections and I want to display all
I am just trying to display a list from an array that I have
How can i display a list of images stored in an array as list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.