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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:10:14+00:00 2026-05-24T10:10:14+00:00

I have many fields that are like this pattern: re2man: (johnny bravo) re1man: (john

  • 0

I have many fields that are like this pattern:

    re2man: (johnny bravo)
re1man: (john smith)......

user: (firstname lastname)..

I wanted to use regex, or another php function to get only characters before the colon (“:”)

  • 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-24T10:10:17+00:00Added an answer on May 24, 2026 at 10:10 am

    Look at explode() to simply split the string at the ‘:’.

    For instance, list($username) = explode(':', $string);

    (list() is being used to assign just the first part of the exploded string to $username and discard the rest; a longer way to do it would be:

    $parts = explode(':', $string);
    $username = $parts[0];
    

    Also, you could use the extra limit parameter to indicate that you don’t need the rest of the parts, like:

    list($username) = explode(':', $string, 1);

    That may or may not be faster. Also, I would expect using explode() to be more efficient than some of the other regex-based solutions offered.

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

Sidebar

Related Questions

I have a user table that has many columns, it looks roughly like this:
I have two tables with identical fields that share many rows. I'd like to
I have a dynamic form that allow to add many fields dynamically, I Know
I have many different small classes which have a few fields each, e.g. this:
I have a favorite table containing some fields like login_id,driver_id(One login_id may have many
I have a form that have many text fields and all are being validated,
I have many cursors that all return rows with the same fields: a numeric
I have found some similar questions like this one, however there are so many
I have very long multidimensional array that have many sub arrays. I would like
I have a model with many fields (nearly 40). The client wants the fields

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.