Your RegEx is different than your html-input, just compare:
<input value="2530317385" name="X-Tmx-session-id" id="X-Tmx-session-id" type="hidden">
~<input type=hidden id=X-Tmx-session-id name=X-Tmx-session-id value=(.*?) \/>~
The quotes are missing, the position requested by RegEx is different.
If you're getting an html by curl
, why not use the DOM to get the elements? For example:
$get = '<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<input value="test1">
<input value="test2">
<input value="test3">
</body>
</html>';
$doc = new DOMDocument();
@$doc->loadHTML($get); //O @ previne mostrar erro de HTML
$allInputs = $doc->getElementsByTagName('input');
foreach ($allInputs as $input) {
echo $input->getAttribute('value'), '<br>';
}
Or with XPath (you may need more advanced selectors):
<?php
$get = '<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<input value="2530317381" name="X-Tmx-session-id" id="X-Tmx-session-id" type="hidden">
<input value="2530317382" name="X-Tmx-session-id" id="X-Tmx-session-id" type="hidden">
<input value="2530317383" name="X-Tmx-session-id" id="X-Tmx-session-id" type="hidden">
<input value="2530317384" name="X-Tmx-session-id" id="X-Tmx-session-id" type="hidden">
</body>
</html>';
$doc = new DOMDocument();
@$doc->loadHTML($get);
$xpath = new DOMXpath($doc);
$doc = NULL;
$allInputs = $xpath->query('*/input[@id=\'X-Tmx-session-id\']');
foreach ($allInputs as $input) {
echo $input->getAttribute('value'), '<br>';
}
Example online: link