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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:56:52+00:00 2026-05-31T19:56:52+00:00

I have for cycle and there I create an array of names from the

  • 0

I have for cycle and there I create an array of names from the list, and what I need to do is remove duplicate values, then I get this array:

Array ( [0] => Tod [1] => Admin [2] => Tod )

    $c=count($_SESSION['cart']);

$list_array = array();

    for($i=0;$i<$c;$i++){
    $id=$_SESSION['list'][$i]['id'];
    $person=get_person($id);

   $list_array[] = $person;
}
  • 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-31T19:56:54+00:00Added an answer on May 31, 2026 at 7:56 pm

    Use array_unique, which returns a new array without duplicate values.

    $input = array("a" => "green", "red", "b" => "green", "blue", "red");
    $result = array_unique($input);
    

    Outputs

    Array
    (
        [a] => green
        [0] => red
        [1] => blue
    )
    

    Check it out here.

    However, you need to move $list_array outside of your for loop, and use that array in your conditionals like so,

    $c=count($_SESSION['cart']);
    
    // if this is in the loop, it will get overwritten
    $list_array = array(); 
    
    for($i=0;$i<$c;$i++){
        $id=$_SESSION['list'][$i]['id'];
        $person=get_person($id);
    
        // originally, you had $users_array in in_array and array_push
        if(!in_array($person, $list_array ))
            $list_array[] = $person;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have such a class: public class Cycle { public List<int> Edges { get;
Is there a way to get the the current position of an array from
I have implemented the Jquery cycle plugin on my page but I can't get
I have played around and implemented JQuery cycle to create a carousel with images,
Im trying to create web Workers and post messages to them in cycle: array.forEach(function
I have a multithreaded program where I create a generator function and then pass
I have another question for the brilliant minds out there (this site is so
I've this question from an assignment to create a Store which rent out books,
I have three images that I want to cycle through when clicking on a
I have a division operation inside a cycle that repeats many times. It so

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.