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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:25:31+00:00 2026-05-27T13:25:31+00:00

I have been looking for an answer for this, but none seem to actually

  • 0

I have been looking for an answer for this, but none seem to actually help my specific situation. I’m trying to post a list of words and then remove the duplicate data (words) that come from the form.

For some reason I can’t seem to get array_unique to work. PHP keeps giving me errors saying my post array is a string. But if I try using explode, it says I’m using an array. Really confused right now and very frustrated.

My code is simple:

if(!empty($_POST['keywords']))
{
    $posted = $_POST['keywords'];

    $posted = array_unique($posted);

    echo $posted;
}

I’m not necessarily looking for an exact answer, but some guidance so I can better understand what I’m doing wrong here.

The form:

    <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
    <p>
        <textarea name="keywords" rows="20" columns="120"></textarea>
    </p>

    <p>
        <input type="submit" name="submit" />
    </p>
</form>
  • 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-27T13:25:32+00:00Added an answer on May 27, 2026 at 1:25 pm

    Consider first splitting the keywords argument by spaces, then finding the unique values:

    $posted = array_unique(explode(' ', str_replace("\n", ' ', $posted)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking on Stack overflow but none of the answers seem to
Hi guys I have been looking around for the answer to this but have
I have been looking for an answer to this, but neither SO nor the
I have been looking all over for an answer to this question, but can't
I have been looking for this on Stack Overflow, but couldnt find an answer
I have been looking around for this but couldn't find an answer anywhere, so
I have been looking around for an answer to this, but haven't been able
I have been looking for an answer to this and could not find it
I have been looking for an answer to this for awhile and haven't found
I have been looking around for an answer to my question but couldn't find

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.