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

The Archive Base Latest Questions

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

Ok, since I never really got an hang on regex in PHP, it would

  • 0

Ok, since I never really got an hang on regex in PHP, it would be awesome if someone could link to a understandable article…

In this case i want to find a value in a string.

if example

$string = "blah blah blha lorem ipsum [get_this_value=10] more lorem ipsum";

i would like a function that returns “10”. it would be loverly if it was stored in array and that the function can retrieve many of them if there’s multiple of these i want them in an array.

$string = "blah blah blha lorem ipsum [get_this_value=10] more lorem ipsum [get_this_value=9] etc etc";

would return array(10, 9) and so on…

  • 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-14T10:31:09+00:00Added an answer on June 14, 2026 at 10:31 am

    First you should learn about regular expressions. I can highly recommend this tutorial.

    Then you can read up on some PHP specific regex issues in PHP’s documentation.

    But to get you started, this would solve your problem:

    preg_match_all("/\[[^\]=]*=(\d+)\]/", $string, $matches);
    

    Now $matches[1] will be your desired array. Note that this does not depend on the specific string get_this_value.

    For the purpose of you actually teaching yourself some regular expressions through the linked pages, I will not explain this regex in detail, but instead just tell you the concepts I have used. Unescaped square brackets [...] mark a character class. In this case (due to the ^) a negated one. \d is a built-in character class. + is a repetition quantifier. And parentheses (...) mark a capturing group.

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

Sidebar

Related Questions

Yesterday, I asked this question and never really got an answer I was really
I've seen many questions about this, but i've never really got the answer that
This is a thing that I never quite got with const-ref and I really
Since Microsoft created MSTest, I've been using it for unit testing. I never really
Heads up: This is a weird question. I've got some really useful macros that
[ EDIT - I long since forgot this was here until I got the
I have been working on Hibernate since sometime and I never really paid attention
I'm having trouble finding why I never get to viewDidLoad since I added my
Since I have no errors I don't know if this is the right place
I've got this HTML form where I have multiple input elements: text, radio, and

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.