Bu soru burada zaten bir cevabı var:
- PHP Foreach Loop and DOMNodeList 2 answers
Bu soru burada zaten bir cevabı var:
Aşağıda bir foreach ile bunu nasıl bir örnektir. Her zaman kullanabilirsiniz, ancak $cols->length
ayrıca döngüsü kullanarak sorununuzu çözecek listesinde düğümlerin sayısını alır.
// assume there is an array initialized called outside of the loop for the rows called $lines
$cols = $row->getElementsByTagName("td");
$row = array();
foreach($cols as $item)
{
$raw = $item->nodeValue;
$row[] = '"'.trim(iconv("UTF-8", "ASCII//IGNORE", $raw)).'"';
}
$lines[] = implode(',', $row); // turn the array into a line
// this is outside the loop for rows
$output = implode("\n", $lines);