Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
September 26, 2006, 9:03 pm
rate this thread
Where I'm replacing "action=move_image" with "action=<?=
I'm using regular expressions to do just that, or at least I'm trying:
$html = preg_replace('/([&\?])action=[^&">]*([&"])([^>]*>Go
back.*$)/', '$1action=' . $_REQUEST['refAction'] . '&blah=foo' . $pagQS
. '$2$3', $html);
I'm using "&blah=foo" as my test to see if preg_replace() has taken
place, so far, it hasn't.
Several class methods spawn the query string before "Go back.." several
different ways; however, there will always be a "action=[something]"
within the query string for you to change, just cannot predict where;
furthermore, there MAY also include "refAction=[something]" within the
same query string.
How do I do this either with regular expressions or some other way?
Re: Need regular expression or some easier way to do HTML query string text substitution
IMHO, having multiple methods independently responsible for creating a
complex URL like that, and then having a regular expression to
subsequently "alter" it is likely to be error-prone and a maintenance
I don't know what your exact scenario is, but if I were doing it, I
might maintain an associative array of the GET variables and values e.g.
$variables["section"] = "image";
$variables["refAction"] = "edit";
$variables["action"] = "move_image";
$variables["section"] = "home";
$variables["refAction"] = "delete";
$variables["action"] = "kill_image";
$variables["action"] = "edit";
// convert array contents to a query string