I have this HTML code, using simple HTML DOS to parse the data in my own PHP script.
& lt; Table & gt; & Lt; TR & gt; & Lt; Td square = "header" & gt; Name & lt; / Td> & Lt; Td square = "header" & gt; City & lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td square = "text" & gt; Greg House & lt; / Td> & Lt; Td square = "text" & gt; Century City & lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td square = "text" & gt; Dexter Morgan & lt; / Td> & Lt; Td square = "text" & gt; Miami & lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; I need to get the text inside TDS in an array, example:
$ array [0] = array ('Greg House', 'Century City '); $ Array [1] = array ('Dexter Morgan', 'Miami');
I have tried many ways to get it, but I have failed in each of them and all of them can give me some hands?
should do this:
// Get the table probably just Is the same, in which case only 'table' $ table = $ html- & gt; Search ('# theTable'); // Start the blank Array to store the data array from each line $ theData = array (); Find the // Loop forward ($ '-' tr 'as the $ line) {// line data from every row $ rowData = array (); Find foreign ($ line-> $ cell ('td.text')) {// cell alarms $ rowData [] = $ cell-> internal text; } // row the data array 'array' array $ theData [] = $ rowData; } Print_r ($ theData);
Comments
Post a Comment