If you want to extract some data from some HTML string, the best solution is often to work with the DOMDocument
class, that can load HTML to a DOM Tree.
Then, you can use any DOM-related way of extracting data, like, for example, XPath queries.
Here, you could use something like this :
$html = <<<HTML
<form action="blabla.php" method=post>
<input type="text" name="campaign">
<input type="text" name="id" value="this-is-what-i-am-trying-to-extract">
</form>
HTML;
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$tags = $xpath->query('//input[@name="id"]');
foreach ($tags as $tag) {
var_dump(trim($tag->getAttribute('value')));
}
And you'd get :
string 'this-is-what-i-am-trying-to-extract' (length=35)