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

  • Home
  • SEARCH
  • 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 8076813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:20:35+00:00 2026-06-05T15:20:35+00:00

THE ANSWER THAT WORKED FOR ME BASED ON AN ANSWER GIVEN while($post = mysql_fetch_array($tags))

  • 0

THE ANSWER THAT WORKED FOR ME BASED ON AN ANSWER GIVEN

while($post = mysql_fetch_array($tags)) {
        $push = explode(',', $post['tags']);
        $array = array_merge($array, $push);
}

So I’m trying to display tags from my data base and make links out of them like this:

<?
$tags = mysql_query( 'SELECT tags  FROM `Table`');
$array = array();
while($post = mysql_fetch_array($tags)) {
$push = explode(',', $post['tags']);
array_push($array, $push);
}
foreach ($array as $value) {?>
    <a href="url.php?tags=<? echo $value?>"><? echo $value?></a>
<? }
?>

However all I get back is

    <a href="url.php?tags=Array">Array</a>

Where I should be having at least three lines as was previously produced by

<?
$tags = mysql_query( 'SELECT tags  FROM `Table`');
while($post = mysql_fetch_array($tags)) {
$array = explode(',', $post['tags']);
foreach ($array as $value) {?>
<a href="url.php?tags=<? echo $value?>"><? echo $value?></a>
<? }
}
?>

The code being called looks like this:

tag1, tag2, tag3

Tried

while($post = mysql_fetch_array($tags)) {
    $push = explode(',', $post['tags']);
array_merge($array, $push);
}
foreach ($array as $value) {?>
<a href="index.php?tags=<? echo $value?>"><? echo $value?></a>

now foreach doesn’t return a value

  • 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-06-05T15:20:37+00:00Added an answer on June 5, 2026 at 3:20 pm

    Use array_merge(), because array_push() will push the output of explode(), which is an array, as a whole to the array in the first argument, creating a jagged array.

    As for your edit, this works:

    $array = array_merge($array, $push);
    
    foreach ($array as $value)
    {
        echo '<a href="url.php?tags=' . $value . '">' . $value . '</a>';
    }
    

    Please note that array_merge() (contrary to array_push(), gotta love the consistency) does not alter the array passed as its first argument, so you’ll have to store the return value which I do on the first line ($array = ...).

    While outputting to HTML, you also might want to put a $value = htmlentities(trim($value)); in the foreach loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the following question, I am looking for an answer that is based on
A while ago, I wrote a web-based guestbook application that wrote it's own database.
Update: I've added an answer that describes my final solution (hint: the single Expr
I ask a similar question here and Darin Dimitrov answer that we can't use
I've been search and I can't found an answer that works, I need to
In this question , Codygman gave an answer that some operators offer a way
I've searched for a question for hours and I haven't found an answer that
I am developing a poll using ruby, but the answer that i get is
I have seen many answers on stackoverflow, but I didn't find an answer that
I found the following answer to that question: A service opens before you even

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.