| preg match to get value
|
ahmed24

msg:4234432 | 11:58 am on Nov 24, 2010 (gmt 0) | hello, i've got a variable called $content that has the following html field <input type="hidden" name="POID" value="125233"> the field varies from time to time and i'd like to know how I can retrieve the value of POID using preg_match any ideas?
|
Readie

msg:4234942 | 3:57 pm on Nov 25, 2010 (gmt 0) | preg_match('/<input[^>]*?value="([^"]*)"[^>]*?>/mis', $content, $out); echo $out[1];
|
Matthew1980

msg:4235005 | 7:34 pm on Nov 25, 2010 (gmt 0) | Hi all, Cheers Readie, I have been trying to figure that one out for most of today! Is there any way of using the \d switch in that to 'condense' the pattern in anyway? I know I am being cheeky in asking that, but in essence, ahmed24 you have a working solution there; I tried this myself, as I wanted something similar to this a while back... Kudos to Readie! Cheers, MRb
|
Readie

msg:4235047 | 9:26 pm on Nov 25, 2010 (gmt 0) | Suppose you could change ([^"]*) to (\d*) - didn't want to assume that the value was only ever going to be an int field though :) Made a mistake in the whole thing anyways. Will just grab the first input atm :)
preg_match('/<input[^>]*?(?:name="POID"[^>]*?value="([^"]*)"|value="([^"]*)"[^>]*?name="POID")[^>]*?>/mis', $content, $out); echo $out[1] Should do the trick
|
|
|