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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:51:47+00:00 2026-05-29T14:51:47+00:00

everywhere I found solutions for removing duplicate entries in php or mysql. But all

  • 0

everywhere I found solutions for removing duplicate entries in php or mysql. But all those solutions removed the whole row, but I just want to remove the value of a column. for example I have this SELECT in mysql:

SELECT HE_FRUIT as fruit, CA_FRUIT as candy, CA_FRUIT_NAME as name, CA_FRUIT_color as color 
FROM fruits LEFT JOIN candy ON HE_FRUIT_ID = CA_FRUIT_ID 
WHERE CA_FRUIT_COUNTRY LIKE '%usa%' 
GROUP BY CA_FRUIT_TITLE 
ORDER BY CA_FRUIT_PRIO, CA_FRUIT_HE

I print the array and I get this:

array
  0 => 
      array
      fruit = "APPLE"
      candy = "lolly"
      name = "xxx"
      color = "green"
   1 => 
      array
      fruit = "APPLE"
      candy = "gum"
      name = "xxx"
      color = "blue"
  2 => 
      array
      fruit = "APPLE"
      candy = "candy"
      name = "xxx"
      color = "red"
  3 => 
      array
      fruit = "BANANA"
      candy = "lolly"
      name = "xxx"
      color = "yellow"

What I want to have is:

  0 => 
      array
      fruit = "APPLE"
      candy = "lolly"
      name = "xxx"
      color = "green"
   1 => 
      array
      fruit = ""
      candy = "gum"
      name = "xxx"
      color = "blue"
  2 => 
      array
      fruit = ""
      candy = "candy"
      name = "xxx"
      color = "red"
  3 => 
      array
      fruit = "BANANA"
      candy = "lolly"
      name = "xxx"
      color = "yellow"

So it’s only the value of the column fruit that should be removed, but all the rest should stay.

Does someone has an idea how I could solve this problem, without to much extra code?

Thanks so much in advance?

  • 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-29T14:52:04+00:00Added an answer on May 29, 2026 at 2:52 pm

    Try this :

    <?php
    
        $data = array(
          0 => array(
              'fruit' => "APPLE",
              'candy' => "lolly",
              'name' => "xxx",
              'color' => "green"
          ),
          1 => array(
              'fruit' => "APPLE",
              'candy' => "gum",
              'name' => "xxx",
              'color' => "blue"
          ),
          2 => array(
              'fruit' => "APPLE",
              'candy' => "candy",
              'name' => "xxx",
              'color' => "red"
          ),
          3 => array(
              'fruit' => "BANANA",
              'candy' => "lolly",
              'name' => "xxx",
              'color' => "yellow"
          )
        );
    
        foreach($data as $i => $dataRow)
        {
            foreach($dataRow as $fieldName => $fieldValue)
            {
                for($j=0; $j<$i; $j++)
                {
                    if($data[$j][$fieldName] == $fieldValue)
                    {
                        $data[$i][$fieldName] = '';
                    }
                }
            }
        }
    
        print_r($data);
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked everywhere, but have not found a solution for this issue. I
I've almost looked everywhere but nothing found, so my only hope would be here
I've search everywhere but haven't found what I'mlooking for even though I'm convinced there
I have been searching everywhere but I could not find an answer. I need
I've searched everywhere for this, but I can't seem to find a solution. Perhaps
I've literally looked everywhere on the net and found very little clarification on how
I just found out that stackoverflow has a link to logout every logged computers.
I understand that Exceptions are for exceptional cases [a], but besides just being repeated
Ok, so I'm using the default project found everywhere to show off the Facebook
I've searched everywhere and never found what I was looking for, simple as it

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.