|
jagg wrote: with the code below the output is sort by $verantw but $title and $file in the same row DON'T belong to $verantw.
Bad array structure.
How do I have to make the sort command that $verantw, $title and $file in the row "belongs together"?
Hope you understand my problem......
<?php $handle = opendir('.'); $daten = array();
# $daten['files'] = array();
# $daten['title_tags'] = array();
# $daten['verantw'] = array();
No need for these last three initializations!
while ($file = readdir($handle)) { if (substr($file, -4) == '.htm') {
### $daten['files'][] = $file;
$html = file_get_contents('./' . $file); preg_match_all('/!!!!(.*)!!!!/', $html, $matches); if (isset($matches[1][0])) {
### $daten['verantw'][] = $matches[1][0];
$verantw = $matches[1][0];
// are you sure about $matches[1][0]?
} preg_match_all('!<title>([^<]+)</title>!i', $html, $matches); if (isset($matches[1][0])) {
### $daten['title_tags'][] = $matches[1][0];
$title_tags = $matches[1][0];
// again, are you sure about $matches[1][0]? }
$daten[] = array($file, $verantw, $title_tags);
} }
# sort($daten['verantw']);
usort($daten, 'cmp_function')
/* ***
and cmp_function should be something like
function cmp_function($left, $rite) {
if ($left[1] < $rite[1]) return -1;
return ($left[1] == $rite[1]) ? 0 : 1;
}
$left[1] and $rite[1] are the $verantw column.
*** */
(snip array output)
foreach ($daten as $one_data) {
echo '<tr>';
echo '<td class="whatever" width="33%">', $one_data[0], '</td>';
echo '<td>', $one_data[1], '</td>';
echo '<td>', $one_data[2], '</td>';
echo '</tr>';
}
..... ?>
--
USENET would be a better place if everybody read: | to email me: use | http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" | http://www.netmeister.org/news/learn2quote2.html | header, textonly | http://www.expita.com/nomime.html | no attachments. | | |