0
我有一個擦除表格的函數。該表的<td>
有很多值,當然這是不同的。因此,我需要一個或兩個以上的字符組合,以便無論數值如何都可以得到所有內容。未知文本的字符組合
function scrape_between($data, $start, $end){
$data = stristr($data, $start); // Stripping all data from before $start
$data = substr($data, strlen($start)); // Stripping $start
$stop = stripos($data, $end); // Getting the position of the $end of the data to scrape
$data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape
return $data; // Returning the scraped data from the function
}
$match = $this -> scrape_between($array, '<td (__MAYBE SOME CHARACTER TO GET EVERYTHING NO MATTER WHAT__) class="V1_c01">', "</td>");
編輯:我想做一個foreach,因爲表有不同的ID,所以我想在國外搜索這些。
foreach ($separate_results as $key => $separate_result) {
if ($separate_result != "") {
$table[$key][0]= $this -> scrape_between($separate_result, '<td id="indhold_0_indholdbredvenstre_0_integrationwrapper_1_ctl01_Program_ProgramNormal_Program1_c04_0" class="V1_c04">', "</td>");
}
}
你的問題不清楚。請添加輸入示例和所需輸出 – FuzzyTree
也許DOM解析可以幫助您? http://php.net/manual/de/book.dom.php – Reeno