Jump to content

unique string manipulation *SOLVED*


phporcaffeine

Recommended Posts

Here is the basics of what I am attempting ... and it may be a combination of str & regex .... I don't know.

<?php

$mystring = "date >= '41968880'";

//In the above, " date >= ' " is the given or 'constant', as well as the trailing " ' "

//I need to, through PHP Identify whatever may be between " date >= ' " & " ' " and I also need to

// be able to replace whatever is between " date >= ' " & " ' ".

//I need to be able to do it without damage/change to the 'constant' or 'given' portion of the string.


?>

I would use str_replace but I cannot predict the text of what I would be replacing. I can only predict the 'constant' or 'given' portions of the string.

Any help is appreciated!

TIA
Link to comment
Share on other sites

[!--quoteo(post=374532:date=May 16 2006, 10:40 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 16 2006, 10:40 PM) [snapback]374532[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
$mystring = "date >= '41968880'";
$replacement = 'test';

$mystring = preg_replace("/(.*?')(.*?)(')/", "$1$replacement$3", $mystring);

echo $mystring;    // displays: date >= 'test'
[/code]
[/quote]

Works like a charm bro, ;)
Link to comment
Share on other sites

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.