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
https://forums.phpfreaks.com/topic/9820-unique-string-manipulation-solved/
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, ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.