'"',
'”' => '"',
'—' => '-',
' ' => ' ',
];
$numVersions = [];
foreach($iniEntries as $iniEntry) {
if(!isset($numVersions[$iniEntry['name']]))
$numVersions[$iniEntry['name']] = 0;
$numVersions[$iniEntry['name']]++;
}
// var_dump($numVersions);
$sections = $finalEntries = [];
foreach($iniEntries as $iniEntry) {
if($numVersions[$iniEntry['name']] > 1) {
for($i=1; $i<100; $i++) {
$section = $iniEntry['name'] . $i;
if(!in_array($section, $sections)) {
$sections[] = $section;
break;
}
}
}
else {
$section = $iniEntry['name'];
$sections[] = $section;
}
$entry = "[".$section."]".NL;
if($section != $iniEntry['name']) {
$entry .= "name=".$iniEntry['name'].NL;
}
$descr = $iniEntry['description'];
$descr = strtr($descr, $replaceMap);
// Limit description to 50 lines, if the rest is longer than 100 chars
$numLinebreaks = 0;
$lenDescr = strlen($descr);
for($i=0; $i sum(X)
some text some text some text
total(X)
#', '\\n', $descr); $descr = strip_tags($descr); $descr = preg_replace('#\s+#', ' ', $descr); $entry['description'] = trim($descr); //var_dump($entry); //break(2); $iniEntries[] = $entry; } } //break; } /* * non-parsable date functions: date(time-value, modifier, modifier, ...) time(time-value, modifier, modifier, ...) datetime(time-value, modifier, modifier, ...) julianday(time-value, modifier, modifier, ...) strftime(format, time-value, modifier, modifier, ...) */ $iniEntries[] = [ 'name'=>'DATE', 'declaration'=>'time-value, modifier, modifier, ...', 'category'=>'Date And Time Functions', 'description'=>'All five date and time functions take a time value as an argument. The time value is followed by zero or more modifiers. The strftime() function also takes a format string as its first argument.', ]; $iniEntries[] = [ 'name'=>'TIME', 'declaration'=>'time-value, modifier, modifier, ...', 'category'=>'Date And Time Functions', 'description'=>'All five date and time functions take a time value as an argument. The time value is followed by zero or more modifiers. The strftime() function also takes a format string as its first argument.', ]; $iniEntries[] = [ 'name'=>'DATETIME', 'declaration'=>'time-value, modifier, modifier, ...', 'category'=>'Date And Time Functions', 'description'=>'All five date and time functions take a time value as an argument. The time value is followed by zero or more modifiers. The strftime() function also takes a format string as its first argument.', ]; $iniEntries[] = [ 'name'=>'JULIANDAY', 'declaration'=>'time-value, modifier, modifier, ...', 'category'=>'Date And Time Functions', 'description'=>'All five date and time functions take a time value as an argument. The time value is followed by zero or more modifiers. The strftime() function also takes a format string as its first argument.', ]; $iniEntries[] = [ 'name'=>'STRFTIME', 'declaration'=>'format, time-value, modifier, modifier, ...', 'category'=>'Date And Time Functions', 'description'=>'All five date and time functions take a time value as an argument. The time value is followed by zero or more modifiers. The strftime() function also takes a format string as its first argument.', ]; return finalizeEntries($iniEntries, true); } function gen_mysql(int $port) { // Insert your custom password and port $mysqli = mysqli_connect('localhost', 'root', null, null, $port); $query = mysqli_query($mysqli, "SELECT t.name, t.description, c.name AS categ FROM mysql.help_topic t, mysql.help_category c WHERE t.help_category_id = c.help_category_id AND c.name NOT LIKE 'Internal%' -- and t.name like 'CURRENT_TIMESTAMP' ORDER BY t.name"); if(mysqli_errno($mysqli)) { die ('MySQL connection error: '.mysqli_error($mysqli)); } $iniEntries = []; while($row = mysqli_fetch_object($query)) { $name = $row->name; // Exclude function names with spaces, or other non-word characters: if(!preg_match('#^\w+$#', $name)) { //echo "10\n"; continue; } #echo $name."\n"; $matchCount = preg_match( '#\b'.preg_quote($row->name).'\s?\[?\(([^\)]*)\)[^\r\n]*[\r\n](.*)$#is', $row->description, $matches); if(!$matchCount) { //echo "20\n"; continue; } $declaration = trim($matches[1]); $declaration = preg_replace('#[\r\n]#', ' ', $declaration); $description = trim($matches[2]); if(preg_match('#Description\s+\-+[\r\n](.+)#is', $description, $matchesD)) { $description = trim($matchesD[1]); } //$description = preg_replace('#[\r\n]#', ' ', $description); #echo $row->name."\n".$matches[2]."\n".$matches[3]."\n\n"; $iniEntries[] = [ 'name'=>$row->name, 'declaration'=>$declaration, 'category'=>$row->categ, 'description'=>$description, ]; } return finalizeEntries($iniEntries, false); } function gen_pg(): string { /* * https://www.postgresql.org/docs/current/functions-string.html * *
Returns the numeric code of the first character of the argument. In UTF8 encoding, returns the Unicode code point of the character. In other multibyte encodings, the argument must be an ASCII character.
ascii('x')
→ 120
]*>\s*(\w+)
\s*\(([^)]*)\).*
(.+)
#', $doc, $matches); if($numMatches === false) { throw new RuntimeException("Regexp error: ".preg_last_error()); } #var_dump($matches); foreach($matches[1] as $i=>$name) { $iniEntries[] = [ 'name' => strtoupper($name), 'declaration' => trim(strip_tags($matches[2][$i])), 'category' => $category, 'description' => trim(strip_tags($matches[3][$i])), ]; } #break; } return finalizeEntries($iniEntries, true); } // SQLite: # echo gen_sqlite(); // MySQL 5.7: echo gen_mysql(3334); // MySQL 8.3: #echo gen_mysql(3308); // MariaDB 11.7: # echo gen_mysql(3317); // PostgreSQL: #echo gen_pg();