define('PREG_FIND_RECURSIVE', 1); define('PREG_FIND_DIRMATCH', 2); define('PREG_FIND_FULLPATH', 4); define('PREG_FIND_NEGATE', 8); define('PREG_FIND_DIRONLY', 16); define('PREG_FIND_RETURNASSOC', 32); define('PREG_FIND_SORTDESC', 64); define('PREG_FIND_SORTKEYS', 128); define('PREG_FIND_SORTBASENAME', 256); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTMODIFIED', 512); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTFILESIZE', 1024); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTDISKUSAGE', 2048); # requires PREG_FIND_RETURNASSOC // PREG_FIND_RECURSIVE - go into subdirectorys looking for more files // PREG_FIND_DIRMATCH - return directorys that match the pattern also // PREG_FIND_DIRONLY - return only directorys that match the pattern (no files) // PREG_FIND_FULLPATH - search for the pattern in the full path (dir+file) // PREG_FIND_NEGATE - return files that don't match the pattern // PREG_FIND_RETURNASSOC - Instead of just returning a plain array of matches, // return an associative array with file stats // // You can also request to have the results sorted based on various criteria // By default if any sorting is done, it will be sorted in ascending order. // You can reverse this via use of: // PREG_FIND_SORTDESC - Reverse order of sort // PREG_FILE_SORTKEYS - Sort on the keyvalues or non-assoc array results // The following sorts *require* PREG_FIND_RETURNASSOC to be used as they are // sorting on values stored in the constructed associative array // PREG_FIND_SORTBASENAME - Sort the results in alphabetical order on filename // PREG_FIND_SORTMODIFIED - Sort the results in last modified timestamp order // PREG_FIND_SORTFILESIZE - Sort the results based on filesize // PREG_FILE_SORTDISKUSAGE - Sort based on the amount of disk space taken // to use more than one simply seperate them with a | character // Search for files matching $pattern in $start_dir. // if args contains PREG_FIND_RECURSIVE then do a recursive search // return value is an associative array, the key of which is the path/file // and the value is the stat of the file. Function preg_find($pattern, $start_dir='.', $args=NULL) { static $depth = -1; ++$depth; $files_matched = array(); $fh = opendir($start_dir); while (($file = readdir($fh)) !== false) { if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue; $filepath = $start_dir . '/' . $file; if (preg_match($pattern, ($args & PREG_FIND_FULLPATH) ? $filepath : $file)) { $doadd = is_file($filepath) || (is_dir($filepath) && ($args & PREG_FIND_DIRMATCH)) || (is_dir($filepath) && ($args & PREG_FIND_DIRONLY)); if ($args & PREG_FIND_DIRONLY && $doadd && !is_dir($filepath)) $doadd = false; if ($args & PREG_FIND_NEGATE) $doadd = !$doadd; if ($doadd) { if ($args & PREG_FIND_RETURNASSOC) { // return more than just the filenames $fileres = array(); if (function_exists('stat')) { $fileres['stat'] = stat($filepath); $fileres['du'] = $fileres['stat']['blocks'] * 512; } if (function_exists('fileowner')) $fileres['uid'] = fileowner($filepath); if (function_exists('filegroup')) $fileres['gid'] = filegroup($filepath); if (function_exists('filetype')) $fileres['filetype'] = filetype($filepath); if (function_exists('mime_content_type')) $fileres['mimetype'] = mime_content_type($filepath); if (function_exists('dirname')) $fileres['dirname'] = dirname($filepath); if (function_exists('basename')) $fileres['basename'] = basename($filepath); if (isset($fileres['uid']) && function_exists('posix_getpwuid')) $fileres['owner'] = posix_getpwuid ($fileres['uid']); $files_matched[$filepath] = $fileres; } else array_push($files_matched, $filepath); } } if ( is_dir($filepath) && ($args & PREG_FIND_RECURSIVE) ) { $files_matched = array_merge($files_matched, preg_find($pattern, $filepath, $args)); } } closedir($fh); // Before returning check if we need to sort the results. if (($depth==0) && ($args & (PREG_FIND_SORTKEYS|PREG_FIND_SORTBASENAME|PREG_FIND_SORTMODIFIED|PREG_FIND_SORTFILESIZE|PREG_FIND_SORTDISKUSAGE)) ) { $order = ($args & PREG_FIND_SORTDESC) ? 1 : -1; $sortby = ''; if ($args & PREG_FIND_RETURNASSOC) { if ($args & PREG_FIND_SORTMODIFIED) $sortby = "['stat']['mtime']"; if ($args & PREG_FIND_SORTBASENAME) $sortby = "['basename']"; if ($args & PREG_FIND_SORTFILESIZE) $sortby = "['stat']['size']"; if ($args & PREG_FIND_SORTDISKUSAGE) $sortby = "['du']"; } $filesort = create_function('$a,$b', "\$a1=\$a$sortby;\$b1=\$b$sortby; if (\$a1==\$b1) return 0; else return (\$a1<\$b1) ? $order : 0- $order;"); uasort($files_matched, $filesort); } --$depth; return $files_matched; } ?>
|
|---|
Comparative and superlative - Vergelijkende en overtreffende trap
IntroductionThe comparative and superlative are forms of an adjective which are used to compare two things or people with one another, to evaluate their relative worth. The comparative is used to state that one thing has more ‘value' (bigger, smaller, thinner) than the other. The superlative is used to say that one thing has the highest ‘value' (the biggest, the smallest, the thinnest).
Comparative: formationForming the comparative is easy. As in English, the suffix -er is added to the bare adjective:
Remember to follow the spelling rules when adding the suffix –er: You might have to lose a vowel (groot – groter) or double a consonant (dun – dunner). Some adjectives do not get the suffix –er to form the comparative, but the suffix –der. This happens only when the last sound of an adjective is /r/:
There is one adjective with an irregular comparative which has to be learnt by heart:
Declension of the comparative The comparative is an adjective. Like all other adjectives, it declines if used attributively – i.e. before a noun – except when the noun it precedes is an indefinite neuter noun:
Comparative: useThe comparative is used in Dutch when two or more items are compared. When both of the compared elements are present in the sentence, the word dan (‘than') is used. If the other compared element is not present, dan will not be present either (see the third and last sentences below):
The word dan in these sentences is a subordinating conjunction. In informal spoken Dutch it is possible to hear als instead of dan. However, many people would consider this incorrect. Comparing two items of equal quality The comparative (adjective + -er (dan)) is used to compare two items of different value. Comparing two items of equal quality is done by means of net zo [adjective] (als) or even [adjective] (als):
Do not confuse net with niet: Alan is niet zo lang als Hanna would mean ‘Alan is not as tall as Hanna'. Superlative: formationThe superlative is easy to form: the suffix -st is added to the bare adjective:
There is one adjective with an irregular superlative which has to be learnt by heart:
Superlative: useThe superlative is used in Dutch to say that one thing has the biggest ‘value' (the most beautiful, the oldest, the most expensive, the best).
Declension of the superlative Like the comparative, the superlative is an adjective. Like all other adjectives, it declines if used attributively – before a noun, i.e. an –e will be added if the superlative precedes a noun. The nature of a superlative dictates that this noun is almost always definite:
The second example illustrates a difference in use between Dutch and English. When two items are compared, English uses a comparative rather than a superlative. Non-adjectives with a comparative and superlativeThere are a few words with a comparative and superlative even though they are not adjectives. Their comparatives and superlatives are also irregular:
Look at the following sets of sentences:
Liever and liefst are of course also the comparative and superlative of the adjective lief (sweet, nice): Alan vindt alle meisjes lief maar hij vindt Hanna het liefst = ‘Alan thinks all girls are sweet but he thinks Hanna is the sweetest'.
|