PDA

Просмотр полной версии : вытянуть с страницы все поля hidden


Student :)
05.04.2009, 12:54
Привет всем!
могли бы вы мне помочь? как средствами PHP
с помощью регулярного выражения вытянуть с страницы все поля hidden

<input type="hidden" name="mod" value="addnews" /><input type="hidden" name="ptxfuhkk" value="84a1097b837ba10296c43d16353ca43a" />

чтоб было так
$h1='mod = addnews';
$h2='ptxfuhkk = 84a1097b837ba10296c43d16353ca43a';

заранее спасибо!!!

Vid0k
05.04.2009, 13:04
<?

$string = "<input type="hidden" name="mod" value="addnews" /><input type="hidden" name="ptxfuhkk" value="84a1097b837ba10296c43d16353ca43a" />"

preg_match_all("/<input type=\"hidden\" name=\"(.*?)\" value=\"(.*?)\" \/>/",$string,$match)

print_r($match)


?>

wildshaman
05.04.2009, 13:05
<?
$from='<input type="hidden" name="mod" value="addnews" /><input type="hidden" name="ptxfuhkk" value="84a1097b837ba10296c43d16353ca43a" />';

preg_match_all('|type="hidden" name="(.*?)" value="(.*?)"|is', $from, $out);
for ($i=0; $i<count($out[1]); $i++)
{
$per[$i] = "{$out[1][$i]} = {$out[2][$i]}";
echo "{$out[1][$i]} = {$out[2][$i]}<br>";
}
?>



В массив $per будет писаться то, то тебе нужно, и на экран выводиться.

Student :)
05.04.2009, 13:06
спасибо щас потестим