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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:44:18+00:00 2026-06-09T11:44:18+00:00

I have an array $user[‘123’][]= 2/2/2012; $user[‘123’][]= 2/3/2012; $user[‘123’][]= 2/4/2012; [‘123’] => Array (

  • 0

I have an array

$user['123'][]= 2/2/2012;
$user['123'][]= 2/3/2012;
$user['123'][]= 2/4/2012;
  ['123'] => Array
    (
        [0] => 2/2/2012
        [1] => 2/3/2012
        [2] => 2/4/2012
    )

What I want to do , is to check whether $var=2/3/2012 is in the array or not,

I tried using in_array , it didnt work
any solution would be appreciated

  • 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-09T11:44:19+00:00Added an answer on June 9, 2026 at 11:44 am

    Something like this

    <?php
    
    $user['123'][]= '2/2/2012';
    $user['123'][]= '2/3/2012';
    $user['123'][]= '2/4/2012';
    
    function dateIn2DArray($date, $haystack) {
      foreach($haystack as $dates) {
        if (in_array($date, $dates)) {
          return true;
        }
      }
    
      return false;
    }
    
    var_dump(dateIn2DArray('2/2/2012', $user)); // true
    var_dump(dateIn2DArray('2/2/2013', $user)); // false
    

    The function loops over the elements in the array searching it’s children for the date.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my controller I have var $uses = array('User','Customer'); then I am using read
I am using PHP and I have an array of user images that I
I have this code: var a:Array = [ Ramsey, Tusey, Iuser,Sephora,'user', 'reseo', 'nesey', 'sela']
I'm using CakePHP 2.0, I have the following save code: $to_save = array( 'User'
I have array of hashes and i want to check a common field which
I have an array of user inputs ($atts) as key=>value pairs. Some of the
I have the code: $getCookieData = $this->Cookie->read('data'); $getUser = $this->User->find('first', array('conditions' => array('User.username' =>
i have created Array of Linkbutton and when user click on link button it
I have an array with default settings, and one array with user-specified settings. I
I have three Models with the associated properties: Links Model: var $belongsTo = array('LinkCategory');

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.