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 7164683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:06:56+00:00 2026-05-28T14:06:56+00:00

I am working on a project that requires imploding an array with character separation.

  • 0

I am working on a project that requires imploding an array with character separation. I have successfully used join and implode interchangeably in other parts of the project, but I can’t get it to work in this section.

$dbQuery = "SELECT ftc.*, fc.name
            FROM facilities f
            LEFT JOIN facility_to_category ftc ON f.fid = ftc.fid
            LEFT JOIN facility_categories fc ON ftc.cid = fc.cid
            WHERE f.listing_year = '2011'
                AND fc.parent_cid = '2'
              AND f.fid = ('".$listing_fid."')";
    $dbResult = $dbc->query($dbQuery,__FILE__,__LINE__);
    $num_results = $dbc->num_rows($dbResult);
    echo '<h3>Demographics</h3>
    <div>';
    while($catdata = $dbc->fetch($dbResult)) {
        $demographics = array();
        $demographic_names = array('',trim($catdata->name));
        $demographics = implode('  '.chr(149).'   ',$demographic_names);   
        print $demographics; 
    }

The result is this:

Demographics
• Affluent • Children • Hard-to-Reach • Parents

instead of

Demographics
Affluent • Children • Hard-to-Reach • Parents

I’ve tried using double quotes instead of single quotes around ‘.chr(149).’. I’ve tried using commas or bars or just spaces. I’ve tried different ways of trimming and not trimming $catdata->name.

I also thought about trying string concatenation, but then I’ll end up with an extra character at the end instead of the beginning. Implode or join seem the better way to go.

What am I missing?

  • 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-28T14:06:57+00:00Added an answer on May 28, 2026 at 2:06 pm

    Thank you, everyone, for your help! I ended up reformatting the query and array. Here is the final code:

    $dbQuery = "SELECT ftc.*, fc.name
                FROM facilities f
                LEFT JOIN facility_to_category ftc ON f.fid = ftc.fid
                LEFT JOIN facility_categories fc ON ftc.cid = fc.cid
                WHERE f.listing_year = '2011'
                    AND fc.parent_cid = '2'
                  AND f.fid = ('".$listing_fid."')";
        $dbResult = $dbc->query($dbQuery,__FILE__,__LINE__);
        $num_results = $dbc->num_rows($dbResult);
        echo '<h3>Demographics</h3>
        <div>';
        while($catdata = $dbc->fetch($dbResult)) {
            $demographics = array();
            if (is_array($demographics)) {
            $demographic_names[] = trim($catdata->name);
            }
        }
        $demographics = join('  '.chr(149).'   ',$demographic_names);           
        print $demographics; 
    

    The result is:

    Demographics
    Affluent • Children • Hard-to-Reach • Parents
    

    Hopefully this will be helpful to someone else!

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

Sidebar

Related Questions

I have a project I'm working on that requires our WPF application read SMS
I am working on a project that requires an object to have multiple values.
I have been working on a project that requires a bar graph to be
So here's the deal I'm working on a project that requires me to have
I'm working on a project that requires a few h1 tags to have text-shadow
I have a project that I'm working on that requires changing a 'BaseSortedCollection' class
I have a project that I am working on that requires the use of
I have a project that I am working on that requires me to delete
I'm working on a project that requires GUI, but I have no experience with
I am working on a project that requires the manipulation of enormous matrices, specifically

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.