1
0

gen_table.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. $scrapers = [
  3. "web" => [
  4. "DuckDuckGo",
  5. "Brave",
  6. "Yandex",
  7. "Google",
  8. "Google API",
  9. "Google CSE",
  10. "Yahoo! JAPAN",
  11. "Startpage",
  12. "Yep",
  13. "Mwmbl",
  14. "Mojeek",
  15. "Naver",
  16. "Baidu",
  17. "Cốc Cốc",
  18. "Solofield",
  19. "Marginalia",
  20. "Purili",
  21. "wiby"
  22. ],
  23. "images" => [
  24. "DuckDuckGo",
  25. "Yandex",
  26. "Brave",
  27. "Google",
  28. "Google API",
  29. "Google CSE",
  30. "Yahoo! JAPAN",
  31. "Startpage",
  32. "Naver",
  33. "Baidu",
  34. "Solofield",
  35. "Pinterest",
  36. "Flickr",
  37. "Pexels",
  38. "Pixabay",
  39. "Unsplash",
  40. "500px",
  41. "VSCO",
  42. "Imgur",
  43. "FindThatMeme"
  44. ],
  45. "videos" => [
  46. "YouTube",
  47. "Vimeo",
  48. "Sepia Search",
  49. "DuckDuckGo",
  50. "Brave",
  51. "Yandex",
  52. "Google",
  53. "Yahoo! JAPAN",
  54. "Startpage",
  55. "Naver",
  56. "Baidu",
  57. "Cốc Cốc",
  58. "Purili",
  59. "Solofield"
  60. ],
  61. "news" => [
  62. "DuckDuckGo",
  63. "Brave",
  64. "Google",
  65. "Yahoo! JAPAN",
  66. "Startpage",
  67. "Baidu"
  68. ],
  69. "music" => [
  70. "SoundCloud",
  71. "Swisscows"
  72. ],
  73. "autocomplete" => [
  74. "Brave",
  75. "DuckDuckGo",
  76. "Yandex",
  77. "Google",
  78. "Qwant",
  79. "Marginalia",
  80. "YouTube",
  81. "SoundCloud",
  82. "Startpage",
  83. "Kagi"
  84. ]
  85. ];
  86. $lines = [
  87. 0 => "",
  88. 1 => ""
  89. ];
  90. // get longest scraper string
  91. // also get list of scrapers with most entries
  92. $biggest_category_len = 0;
  93. foreach($scrapers as $category_name => $category){
  94. $count = count($category);
  95. if($count > $biggest_category_len){
  96. $biggest_category_len = $count;
  97. }
  98. }
  99. foreach($scrapers as $category_name => $category){
  100. // get longest string of the category
  101. $longest_len = mb_strlen($category_name);
  102. foreach($category as $scraper){
  103. $strlen = mb_strlen($scraper);
  104. if($strlen > $longest_len){
  105. $longest_len = $strlen;
  106. }
  107. }
  108. // add header
  109. $lines[0] .= mb_str_pad("| {$category_name}", $longest_len + 3);
  110. $lines[1] .= "|" . str_repeat("-", $longest_len + 2);
  111. for($i=2; $i<count($category) + 2; $i++){
  112. if(!isset($lines[$i])){
  113. $lines[$i] = "";
  114. }
  115. $lines[$i] .= mb_str_pad("| {$category[$i - 2]}", $longest_len + 3);
  116. }
  117. if($i - 2 < $biggest_category_len){
  118. for($k=$i; $k<$biggest_category_len + 2; $k++){
  119. if(!isset($lines[$k])){
  120. $lines[$k] = "";
  121. }
  122. $lines[$k] .= "|" . str_repeat(" ", $longest_len + 2);
  123. }
  124. }
  125. }
  126. foreach($lines as $line){
  127. echo $line . "|\n";
  128. }