// Convert &|&action=...
$output = preg_replace('/' . $target2 . '(.*)&action=/i', $action, $output);
// "The same procedure as last variable"... now for &what=
// Convert &|&action=...
$output = preg_replace('/' . $target2 . '(.*)&action=/i', $action, $output);
// "The same procedure as last variable"... now for &what=
$output = preg_replace('/' . $target2 . '(.*)&what=/i', $what, $output);
// Repair missed &what=??? entries
$output = preg_replace('/' . $target2 . '(.*)&what=/i', $what, $output);
// Repair missed &what=??? entries