Ok, I have page with something like this (I added 'scrapehere' string to make it easier to navigate, this page isn't 100% correct html and it has two identical fields with different values. No, I can't fix it because it's cms i'm using and i feel it would be too complicated for me to do):
scrapehere<input type="hidden" id="_someid" name="_somename" value="value"/>
I'm trying to get hidden value. So I wrote such script:
<?php
$data = file_get_contents('scrape-test.html');
$regex = '/scrapehere<input type="hidden" id="_someid" name="_somename" value="(.+?)"/';
preg_match($regex,$data,$match);
var_dump($match);
echo $match[1];
?>
But instead of my value script outputs this:
array(2) { [0]=> string(74) "scrapehere string(5) "value" } value
What's wrong with it, why won't it just print value? Did it already saved it somewhere but my echo is wrong? I want output to be just value
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…