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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:03:49+00:00 2026-06-17T18:03:49+00:00

$details = text…[book=123]…text…; $details = preg_replace_callback( /\[book=(.+?)\]/smi, function ($m) { global $skip_books; $book =

  • 0
$details = "text...[book=123]...text...";

$details = preg_replace_callback(
  "/\[book=(.+?)\]/smi",
  function ($m) {
      global $skip_books;
      $book = $m[1];  // 123
      $feed = $m[2];  // 456       
  return "<div id=\"view_book_".$book."_".$feed."\"></div>";
  },
  $details
);

With this pattern i can only get $book ($m[1]):

"/\[book=(.+?)\]/smi"`

But i want to get $feed ($m[2]) too, so i replace to this [book=123_456].

How to get “456” ($m[2]) after the underline?

"/\[book=(.+?)_(.+?)\]/smi" ???
  • 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-17T18:03:50+00:00Added an answer on June 17, 2026 at 6:03 pm

    Don’t use global here; you’re already using a closure, so use the use:

    function ($m) use ($skip_books) {
        // ...
    }
    

    Btw, you’re not actually using $skip_books in the code you’ve shown so far, but I’m assuming that’s because you’ve simplified it

    If your arguments are always numbers, don’t use something generic like (.+?) but be specific (the more the better):

    /\[book=(\d+)_(\d+)\]/i
    

    I’ve also removed the /s and /m modifiers, which are useless here.

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

Sidebar

Related Questions

I have a div containing text and image and text details within ul li
Details on fonts: When you have some text in specific font, there's a header
I want all build details to be saved in a text file.How to get
I have a HTML page with personal information details using text boxes. I have
I have the following code in my app which changes the cell details text
I have a span on page with the text Details for item 1 bla-bla-bla.
Is it possible to create a button with WinForms which has the text Details
Hey guys here is my code: <script>$('td#view-details').click(function() { var fg = $(this).closest('td').siblings(':first-child').text(); $('#'+fg+'confirm').click(function ()
<?php class Form_Audience extends Zend_Form_SubForm { public function init() { $this->setMethod('post'); $this->setLegend('Audience Details'); $this->addElement('text',
In the following code when I echo the text in Details column after retrieving

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.