Forum Moderators: coopster

Message Too Old, No Replies

Match html attributes

         

FiRe

8:23 am on May 24, 2007 (gmt 0)

10+ Year Member



I am trying to write a script that matches all html attributes and puts them into an array:

preg_match_all("/(.*)=\"(.*)\"/", $data, $matches);

So if $data is <story id="1805952" comments="0" status="upcoming"> then $matches should be id=>1805952,comments=>0,status=>upcoming

The code I posted doesn't seem to work well, any ideas?
Thanks in advance :-)

vincevincevince

8:28 am on May 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



preg_match_all("/ (*?)=\"(.*?)\"/", $data, $matches);

That's quick and dirty