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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:52:14+00:00 2026-05-23T15:52:14+00:00

I have an array with a key and 3 values (day, start_time, end_time). I

  • 0

I have an array with a key and 3 values (day, start_time, end_time). I want to keep adding certain entries into this array while making sure each entry is unique. That means that every time I try to add an item into the array, I want to make sure it does not already exist in it. If it does exist, I want to be able to find the key that indicates that entry.

For example, this is the pre-existing array:

$array [0][0] = Monday
$array [0][1] = 2
$array [0][2] = 4
$array [1][0] = Tuesday
$array [1][1] = 3
$array [1][2] = 5

If I try to insert (Wednesday, 3, 5), then it should make the entry in the index 2.

If I try to insert (Monday, 2, 4), I need to be able to know that it is already in there and is indexed by 0.

How do I go about doing this?

  • 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-23T15:52:15+00:00Added an answer on May 23, 2026 at 3:52 pm

    I agree with the other answers here — it might be better to restructure your array so that there is no need to worry about duplication at all.

    If you want to keep your current structure, however: use array_search.

    $array = ...
    $unique_check = array_search(array('Monday', 2, 4), $array);
    
    if ( $unique_check === false )
        // add to array
    else
        // $unique_check = the array key at which the existing matching element is located
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array with alphanumeric key values..While filling array on particular condition I have
i have an array which could look like this: $config[$name][$array]['key'] = 'value'; // here
If I have an array of hashes, each with a day key: [ {:day=>4,:name=>'Jay'},
I have a php array of primary key values, which correspond to just a
I have a array which contains values like this See below for script sample
i have an array with around 10 key values. which is the best way
I have values in some array I want to re index the whole array
I have an array made of: old_array=(color red shape circle vote 10) (alternating key/values)
I have an array of key values {val1: [{gender:male}, {age:23}, {favorite-color:red}] } The thing
Say I have an array of key/value pairs in PHP: array( 'foo' => 'bar',

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.