Jump to content

Recommended Posts

I'VE GOT.

 

question_comment

42

51

553

12

55421

 

answer_comment

3221

321

12

145

667

 

post_comment

12321

1212

1221

1212

11

1

 

 

I WANT.

 

get everything which is after variable, let it be for example: answer_comment, so the result needs to be:

 

3221

321

12

145

667

 

 

so we theoretically delete the variable and we take all until the next "\r\n\r\n"

 

how to do that

any preg_match?

Link to comment
https://forums.phpfreaks.com/topic/252661-how-to-extract-very-simple/
Share on other sites

You will need to use a look-behind. Be aware a look-behind has to be a fixed length (i.e. not a pattern). It would go something like:

 

[This is untested]

<?php
$variable = 'answer_comment';
preg_match("/(?<=$variable)[^A-Za-z]+/sm", $subject, $match);

 

That's looking for something that begins with the variable and is not letters and can happen between one and infinity times.

 

Hope that helps,

Joe

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.