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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:14:31+00:00 2026-06-11T21:14:31+00:00

so i have an array with months: $arr_month = array( 1=>’january’, 2=>’february’, 3=>’march’, 4=>’april’,

  • 0

so i have an array with months:

$arr_month = array(
    1=>'january',
    2=>'february',
    3=>'march',
    4=>'april',
    5=>'may',
    6=>'june',
    7=>'july',
    8=>'august',
    9=>'september',
    10=>'october',
    11=>'november',
    12=>'december'
);

i also have strings (i know, they look weird…) that look like:

23 de january del 2003
12 de may de 1976
6 de february de 1987

What i want is to find and match the month in the string with the array and return the array key.

so:

23 de january del 2003 returns 1
12 de may de 1976 returns 5
6 de february de 1987 returns 2

and so on…

Any idea how?

  • 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-11T21:14:32+00:00Added an answer on June 11, 2026 at 9:14 pm

    This should work for you.

    $dateString = "23 de january del 2003"; // as an example
    $exploded = explode (" ", $dateString); // separate the string into an array of words
    $month = $exploded[2]; // we want the 3rd word in the array;
    $key = array_search ($month, $arr_month); // lets find the needle in the haystack
    print $key;
    

    yields 1.

    See http://php.net/manual/en/function.array-search.php for more.

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

Sidebar

Related Questions

I have an Array with some String objects lets say months. [October] [May] [July]
I have this months array: [January, March, December , October ] And I want
I have an array for months $months[01] = 'January'; $months[02] = 'February'; $months[03] =
I have the following code to get the current day: var month=new Array(12); month[0]=January;
I have an string array of months in C# from jan to dec. I
I have an array of months like this: var months = [jan, feb, mar,
I have a array that contains all the months in a year like so:
I have an array of months (numbers, 1-12) which I want to sort in
I have a php script with an array which loops through months and displays
I have an array: int[] months = new int[4] {1, 4, 7, 10}; I

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.