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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:59:51+00:00 2026-06-18T13:59:51+00:00

This is my first question here and I am messed up with strings. I

  • 0

This is my first question here and I am messed up with strings. I have some strings in the following format:

     I will be here (I may or may not be here) (30-Apr-2013) 
     I am still here (15-Feb-2013)
     I am still here(I may not be here) (I may not be here) (9-Apr-2013) 

I need to separate the date from the name. As you can see, the number of brackets may vary, but I need the last one only ( rest of the string will be treated as name).

Expected output:

1. array( 0=> 'I will be here (I may or may not be here)' , 1=> '30-Apr-2013' )
2. array( 0=> 'I am still here' , 1=> '15-Feb-2013' )
3. array( 0=> ' I am still here(I may not be here) (I may not be here)' , 1=> '9-Apr-2013' )

What is the best way to achieve 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-06-18T13:59:52+00:00Added an answer on June 18, 2026 at 1:59 pm

    You can use strrpos to find the last occurrence of ( and then you can use substr and trim to get the sub-strings and trim them to the result you want.


    E.g.

    /**
     * Return an array with the "name" as the first element and
     * date as the second.
     */
    function fun($string)
    {
        $datePos = strrpos($string, '(');
        return array (
            trim(substr($string, 0, $datePos - 1)), trim(substr($string, $datePos), ' ()')
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first question here and if its format is not what is
this is my first question here :) I know that I should not check
this is my first question.. so, here we go. i have a site, 100%
Sorry, this's my first time to ask a question here. So, I don't have
This is my first question here, and I will try to follow all the
This is my first question here. I have a complicated SQL database and I
This is the first question I've posted here, but have found stack more than
this is my first question here so be gentle ! recently i try to
This is my first question here so try to make my best so you
Ok, I need help. This is my first question here. Background: I am working

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.