Jump to content

Recommended Posts

I'm trying to pull a certain number of characters after a specific character. For example:

 

$data="x=1234567"

 

I'd like to pull 7 characters after "x=". So the result whould be "1234567".

 

I couldn't use strpos because the 7 characters will NOT always begin from the 3rd character. For example, it could be "x=" or "tyx=" or "1x=", etc. I only want what's after "x=".

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/273365-help-with-character-extraction/
Share on other sites

What's wrong with just substr (), I mean if you know you always want 7 characters?

php > $data="x=1234567";
php > echo substr ($data, -7);
1234567

 

Otherwise, you can use strpos () to find the position of the equals sign, and send that value to substr ().

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.