Using php and regex to grab labels and data and store as associative array -
How can I use regex to find this table in one page (by searching by name it): < / P> Then grab "label" and "datainfo" and store them in a companion array such as: Reggae is a bad solution in this case. Use instead Update: Here's the function for:
< / Div> $ table_name [name] // content $ Table_name [email] // Stuff2 $ table_name [address] // Stuff3 $ table_name2 [field1] // more info $ table_name2 [field2] // morestaf 2 $ table_name2 [field3] // morefirst 3
$ html = str_get_html ($ html); Print_r (get_table_fields ($ html, 'table name')); Print_r (get_table_fields ($ html, 'Table Name 2')); Function get_table_fields ($ html, $ id) {$ table = $ html- & gt; Search ('table [id ='. $ Id. ']', 0); Find foreign currency ($ table-> as line $ ('tr')) {$ key = $ row-> Search ('TD', 0) - & gt; Plain text; $ Value = $ row-> Find ('TD', 1) - & gt; Plain text; ## Finish ':' symbol $ key = preg_replace ('/: $ /', '', $ key); $ Result [$ key] = $ value; } Return result; }
Comments
Post a Comment