Hi,
with the code below the output is sort by $verantw but $title and
$file in the same row DON'T belong to $verantw.
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();
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];
}
preg_match_all('!<title>([^<]+)</title>!i', $html, $matches);
if (isset($matches[1][0])) {
$daten['title_tags'][] = $matches[1][0];
}
}
}
sort($daten['verantw']);
$nr = 0;
$max = count($daten['verantw']);
for ($i = 0; $i < $max; $i++) {
echo "<tr>";
echo "<td class=\"text\" width=\"4%\">".++$nr."</td>";
echo "<td class=\"text\" width=\"28%\"><a class=\"link\"
href=\"".$daten['files'][$i]."\"
target=\"_blank\">".$daten['files'][$i]."</a></td>";
echo "<td class=\"verantw\" width=\"25%\">";
if ($daten['verantw'][$i]) echo $daten['verantw'][$i];
else echo ' ';
echo "</td>";
echo "<td class=\"text\" width=\"35%\">";
if ($daten['title_tags'][$i]) echo $daten['title_tags'][$i];
else echo ' ';
echo "</td>";
......
?> 2 1727
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. |
Pedro, THANK YOU SO MUCH!!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Philips |
last post by:
I recently had the need to sort a large number of lists of lists, and
wondered if an improvement to the Decorate-Sort-Undecorate idiom is in
the works. Ideally, I would like to sort the list of...
|
by: Kamilche |
last post by:
I've written a generic sort routine that will sort dictionaries,
lists, or tuples, either by a specified key or by value.
Comments welcome!
import types
def sort(container, key = None,...
|
by: its me |
last post by:
Let's say I have a class of people...
Public Class People
Public Sex as String
Public Age as int
Public Name as string
end class
And I declare an array of this class...
|
by: Shi Mu |
last post by:
Got confused by the following code:
>>> a
>>> b
>>> c
{1: , ], 2: ]}
>>> c.append(b.sort())
>>> c
{1: , ], 2: , None]}
|
by: Alex Chudnovsky |
last post by:
I have come across with what appears to be a significant performance bug in
..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same
data. Same data on the same CPU gets sorted a...
|
by: Raj |
last post by:
We are on a db2 v8.2 (fix 8) with DPF & intra parllelism. Below are
sort related configuration settings
...
|
by: Woody Ling |
last post by:
In 32 bits DB2 environment, is it meaningful to set sheapthres larger
than 256MB for the following case..
1. Intra-parallel is ON
2. Intra-parallel is OFF
|
by: neehakale |
last post by:
I know that heap sort,quick sort and merg sort are the faster sorting algoritms than the bubble sort,selection sort,shell sort and selection sort.
I got an idea,in which situation we can use...
|
by: aRTx |
last post by:
I have try a couple of time but does not work for me
My files everytime are sortet by NAME.
I want to Sort my files by Date-desc.
Can anyone help me to do it?
The Script
<?
/*
ORIGJINALI
|
by: raylopez99 |
last post by:
This is an example of using multiple comparison criteria for IComparer/
Compare/CompareTo for List<and Array.
Adapted from David Hayden's tutorial found on the net, but he used
ArrayList so the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |