Jump to content

Recommended Posts

$text = 'datetime_system=>2010-10-14 02:07:07{~-SePaRaT0R-~}username_system=>test (16){~-SePaRaT0R-~}ip_system=>79.354.76.127';
preg_match('~.*username_system=>.* \(([0-9]+)\).*~i', $text, $matches);

echo $matches[1];

 

Should do what you are looking for.

well if you have control over what the format of $text is and you need it to be a string, I would suggest you serialize the data (array) into a string for $text and then unserialize $text when you need it, which will restore it to the original array. 

 

If you do not have access to change the format of the $text string, assuming the format is regular (looks like what you have up there, but all the time), you could explode at the delimiter loop through and explode at => for the key => value pairs, basically simulating unserialize().  Though you may run into issues if values happen to be your delimiter or => as well...

 

Otherwise the safest way to do it would probably be to do what premiso suggested.

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.