poe Posted November 20, 2006 Share Posted November 20, 2006 i have a series of radio buttons lik so:<input type="radio" name="0SelectedOdds2" value="4.5" onclick="updatePayout(this,'1057','2006-11-19 00:00:00.0','Sunday, November 19, 2006','22','10:00PM','HKY','CHI','VAN','V+','0','You can only pick a maximum of 6 odds','')">i want to loop through each button and extract all the parts into different varsso far i have:preg_match_all("/<input type=(\"|\')?radio[^>]*>/", $html, $match_radio, PREG_SET_ORDER);but that only extrracts the radio buttons from the page. how do i get all the different parts within the radiobutton. the result i want is:$name = '0SelectedOdds2'$value = '4.5'$card = '1057'$gtmdate = '2006-11-19 00:00:00.0'$longdate = 'Sunday, November 19, 2006'$gameid = '22'$gametime = '10:00PM'$sport = 'HKY'$visitor = 'CHI'$home = 'VAN'$radioid = 'V+'$radiofield = '0'$rules = 'You can only pick a maximum of 6 odds'$tbafield = '' Quote Link to comment Share on other sites More sharing options...
Nicklas Posted November 20, 2006 Share Posted November 20, 2006 [code=php:0]preg_match_all('/(?<=name=").*?(?=")|(?<=value=").*?(?=")|(?<=,\').*?(?=\')/', $string, $matches);list( $name, $value, $card, $gtmdate, $longdate, $gameid, $gametime, $sport, $visitor, $home, $radioid, $radiofield, $rules, $tbafield ) = $matches[0];[/code] Quote Link to comment Share on other sites More sharing options...
poe Posted November 20, 2006 Author Share Posted November 20, 2006 still cant get it to work, if i go:[code]$string = " <input type=\"radio\" name=\"0SelectedOdds2\" value=\"4.5\" onclick=\"updatePayout(this,'1057','2006-11-19 00:00:00.0','Sunday, November 19, 2006','22','10:00PM','HKY','CHI','VAN','V+','0','You can only pick a maximum of 6 odds','')\"> ";preg_match_all('/(?<=name=").*?(?=")|(?<=value=").*?(?=")|(?<=,\').*?(?=\')/', $string, $matches);list($name,$value,$card,$gtmdate,$longdate,$gameid, $gametime,$sport,$visitor,$home,$radioid,$radiofield,$rules,$tbafield) = $matches[0];print_r($matches)[/code]i get:Array ( [0] => Array ( ) ) Quote Link to comment Share on other sites More sharing options...
Nicklas Posted November 20, 2006 Share Posted November 20, 2006 Hmm, it works for me. My array looks like this:[CODE]Array( [0] => Array ( [0] => 0SelectedOdds2 [1] => 4.5 [2] => 1057 [3] => 2006-11-19 00:00:00.0 [4] => Sunday, November 19, 2006 [5] => 22 [6] => 10:00PM [7] => HKY [8] => CHI [9] => VAN [10] => V+ [11] => 0 [12] => You can only pick a maximum of 6 odds [13] => ))[/CODE]I´m using PHP5 and some people have had problems using regexp´s with assertions when using a PHP version < PHP5, what version arae you using?Anyways, if you cant get it to work, then you could try this regexp without assertions:[hr][code=php:0]preg_match_all('/name="(.*?)"|value="(.*?)"|,\'(.*?)\'/', $string, $matches);$matches[3][0] = $matches[1][0];$matches[3][1] = $matches[2][1];print_r($matches[3])[/code][hr]This regexp works for me to and the result is the same as my array above. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.