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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:30:13+00:00 2026-06-15T09:30:13+00:00

I have a sentence in PHP that I’ve broken down into its word components

  • 0

I have a sentence in PHP that I’ve broken down into its word components using explode.

foreach ($words as $splitword)
{
    echo $splitword;
    /* echo "<a href = 'word.php?word=" . $splitword . "'>" . $splitword . "</a>"; */
    echo " ";
}

What I want to do is make each word clickable, so I echo each word followed by a space. Now, using the code you see above, everything looks fine and natural. However, if I uncomment the commented line, and comment out echo $splitword;, so that I’m now echoing links instead of just the word, things get ugly:

  1. echo " " no longer works, I have to use echo "&nbsp"
  2. The spaces are very large. Echoing each word without making it a link produces natural spacing, the way it should be. But when I start using the a tag followed by &nbsp, the spaces are about twice as wide.

Any idea why, and what a workaround is?

  • 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-15T09:30:14+00:00Added an answer on June 15, 2026 at 9:30 am

    echo " " does not work because you are writing HTML, which does not parse ” “.
    You’ll have to use &nbsp; like you already discovered.

    The extra spacing could be your styling. Check your CSS. If you still don’t find anything strange, add this to your CSS:

    a { 
      margin: 0; 
      padding: 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small PHP script that is selecting a random sentence from an
I have to split the word in a sentence which contains more than 40
I have a code snippet written in PHP that pulls a block of text
I have a very strange array sorting related problem in PHP that is driving
I have used a function for formatting in sentence case. My PHP script function
I have predefined words and would like to know if the sentence primary subject
I'm working with long paragraphs of text that are searchable using MySQL and PHP.
I have a text file that maintains a list of words. What I am
I have a custom php script that looks through text to find key phrases
Let's say I have this sentence. The dog took the kid's bone. Well using

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.