Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. $words = array( 'MVW',
  2. 'MWAH',
  3. 'MWAH',
  4. 'MYW',
  5. 'MW',
  6. 'MY9AH',
  7. 'MYQAH',
  8. 'MYQAH',
  9. 'MY9AH',
  10. 'MYQAH',
  11. 'MYQAH',
  12. 'MWAH',
  13. 'MYQAH',
  14. 'MYSWI',
  15. 'MYQAH',
  16. 'MYQAH',
  17. 'MW',
  18. 'MW',
  19. 'MW',
  20. 'MW');
  21.  
  22. 1. char is: M - occurred 20 times as 1. character in words.
  23. 2. char is: Y - 11 times.
  24. 3. char is: Q - 7 times.
  25. 4. char is: A - 10 times.
  26. 5. char is: H - 9 times.
  27.  
  28. <?php
  29.  
  30. $words = array( 'MVW',
  31. 'MWAH',
  32. 'MWAH',
  33. 'MYW',
  34. 'MW',
  35. 'MY9AH',
  36. 'MYQAH',
  37. 'MYQAH',
  38. 'MY9AH',
  39. 'MYQAH',
  40. 'MYQAH',
  41. 'MWAH',
  42. 'MYQAH',
  43. 'MYSWI',
  44. 'MYQAH',
  45. 'MYQAH',
  46. 'MW',
  47. 'MW',
  48. 'MW',
  49. 'MW');
  50.  
  51.  
  52. $newarray = array();
  53. $cc2 = 0;
  54. $cc3 = 0;
  55. $cc4 = 0;
  56. $cc5 = 0;
  57. $cc6 = 0;
  58.  
  59. foreach($words as $run) {
  60.  
  61. if (isset($run['1']) && !isset($run['2'])) {
  62. $newarray[] = array($run['0'],$run['1']);
  63. $cc2++;
  64. }
  65.  
  66. if (isset($run['2']) && !isset($run['3'])) {
  67. $newarray[] = array($run['0'],$run['1'],$run['2']);
  68. $cc3++;
  69. }
  70.  
  71. if (isset($run['3']) && !isset($run['4'])) {
  72. $newarray[] = array($run['0'],$run['1'],$run['2'],$run['3']);
  73. $cc4++;
  74. }
  75.  
  76. if (isset($run['4']) && !isset($run['5'])) {
  77. $newarray[] = array($run['0'],$run['1'],$run['2'],$run['3'],$run['4']);
  78. $cc5++;
  79. }
  80.  
  81. if (isset($run['5']) && !isset($run['6'])) {
  82. $newarray[] = array($run['0'],$run['1'],$run['2'],$run['3'],$run['4'],$run['5']);
  83. $cc6++;
  84. }
  85.  
  86. }
  87.  
  88. echo "Length / Found words<br>n";
  89. echo "2 chars / $cc2<br>n";
  90. echo "3 chars / $cc3<br>n";
  91. echo "4 chars / $cc4<br>n";
  92. echo "5 chars / $cc5<br>n";
  93. echo "6 chars / $cc6<br>n";
  94.  
  95. echo "<pre>";
  96. var_dump($newarray);
  97. echo "</pre>";
  98. ?>
  99.  
  100. Length / Found words
  101. 2 chars / 5
  102. 3 chars / 2
  103. 4 chars / 3
  104. 5 chars / 10
  105. 6 chars / 0
  106. array(20) {
  107. [0]=>
  108. array(3) {
  109. [0]=>
  110. string(1) "M"
  111. [1]=>
  112. string(1) "V"
  113. [2]=>
  114. string(1) "W"
  115. }
  116. [1]=>
  117. array(4) {
  118. [0]=>
  119. string(1) "M"
  120. [1]=>
  121. string(1) "W"
  122. [2]=>
  123. string(1) "A"
  124. [3]=>
  125. string(1) "H"
  126. }
  127. [2]=>
  128. array(4) {
  129. [0]=>
  130. string(1) "M"
  131. [1]=>
  132. string(1) "W"
  133. [2]=>
  134. string(1) "A"
  135. [3]=>
  136. string(1) "H"
  137. }
  138. [3]=>
  139. array(3) {
  140. [0]=>
  141. string(1) "M"
  142. [1]=>
  143. string(1) "Y"
  144. [2]=>
  145. string(1) "W"
  146. }
  147. [4]=>
  148. array(2) {
  149. [0]=>
  150. string(1) "M"
  151. [1]=>
  152. string(1) "W"
  153. }
  154. [5]=>
  155. array(5) {
  156. [0]=>
  157. string(1) "M"
  158. [1]=>
  159. string(1) "Y"
  160. [2]=>
  161. string(1) "9"
  162. [3]=>
  163. string(1) "A"
  164. [4]=>
  165. string(1) "H"
  166. }
  167. [6]=>
  168. array(5) {
  169. [0]=>
  170. string(1) "M"
  171. .........
Add Comment
Please, Sign In to add comment