PHP kezdő oldal!

PHP ASCII count_cahars


Alkalmazott PHP verzió: 7.4.33
Tesztelésekhez elvárt PHP verzió = 5.4.34 vagy újabb.

Ezen fájl kódolása: UTF-8 BOM
<meta charset="UTF-8">


PHP Angol stringekre építkezik.
Ezért probléma az ékezetes karakter.
Problémát a count_chars() megoldja.

Hardvereszközök vezérlésére tervezték. (tartományuk: 0-31, vagy 00-31, és a 127)
A 127 = DEL = delete (rubout) törlés (kiradírozni)
A 32 = Space = Betűköz, azaz, szóköz. Weboldalon nem látható.


Magyar ÁBC esetén, 18 karakter, mely probléma = ÁÉÍÓÖŐÚÜŰáéíóöőúüű
Probléma, az ord() és chr() alkalmazásakor, és ABC rendezésnél van.
count_chars($valami,1); minden stringet beazonosít, de az ord() és chr(), nem minden kapott értéket tud, értelmezni.


A count_chars() beazonosítása alapján, Magyar ékezetesek kulcsai:
[129] = Á; [137] = É; [141] = Í; [147] = Ó; [150] = Ö; [144] = Ő; [154] = Ú; [156] = Ü; [176] = Ű;
[161] = á;  [169] = é;  [173] = í;  [179] = ó;  [182] = ö;  [145] = ő;  [186] = ú;  [188] = ü;  [177] = ű;


count_chars()
Információt ad a karakterláncban ( szövegben ) használt karakterekről.
Például:
Hányszor fordul elő egy ASCII karakter egy karakterláncban, azaz,
mely karaktereket használták vagy nem használták a karakterláncban.

Szintaxisa: count_chars( string,mode )

Parameter	           Leírás
string	        Kötelező. Az ellenőrizendő string, megadása.
mode	         Választható. Megadja a visszatérési módokat. 0 az alapértelmezett.

          Különböző visszatérési módok, a következők:
     0 - tömb, amelynek ASCII-értéke kulcs, az események száma pedig értéke.
     1 - tömb, amelynek ASCII-értéke kulcs és az események száma értéke, csak a nullánál nagyobb eseményeket sorolja fel.
     2 - tömb, amelynek ASCII értéke kulcsként, és az események száma értékként, csak a nullával megegyező események
               kerülnek felsorolásra.
     3 - karakterlánc, az összes használt karakterrel.
     4 - karakterlánc, az összes fel nem használt karakterrel.
			



Példák a módok alkalmazásásra:
  <?php
	$mondat = "Hello World! Ékezetes betűk: áéíóöőúüű.";          // 39 string. Szövegben 11 ékezetes string van.
		$mod0 = count_chars($mondat,0); // Minden string ellenőrzése, és a szereplők értéke, tömbbe gyűjtve.
		$mod1 = count_chars($mondat,1); // Szövegben szereplő stringek, értéke.
		$mod2 = count_chars($mondat,2); // Szövegben nem szereplő stringek, értékeik = 0;
		$mod3 = count_chars($mondat,3); // Szövegben szereplő stringek kiíratása, karakterlácban.
		$mod4 = count_chars($mondat,4); // Szövegben nem szereplő stringek kiíratása, karakterlácban.
		
		// A mód "0" kiíratása. --------------------		
			echo'<pre>';
			print_r($mod0);
			echo'</pre>';
		// A mód "1" kiíratása. --------------------
			echo'<pre>';
			print_r($mod1);
			echo'</pre>';
		// A mód "2" kiíratása. --------------------
			echo'<pre>';
			print_r($mod2);
			echo'</pre>';
		// A mód "3" kiíratása. --------------------
			echo'<pre>';
			print_r($mod3);
			echo'</pre>';
		// A mód "4" kiíratása. --------------------
			echo'<pre>';
			print_r($mod4);
			echo'</pre>';
  ?>
		


A fenti PHP program eredményei.
A 32 kulccsal rendelkező elem, a szóközök előfordulásának számát tárolja.
A 195 és 197 kulccsal rendelkező elemek, a Magyar ékezeteseket összesítik.


Windows rendszeren.
PHP ASCII
String minták.


count_chars módok,
eredményei.

ANSI minta:
ASCII
chr()
0 =
1 = SOH
2 = STX
3 = ETX
4 = EOT
5 = ENQ
6 = ACK
7 = BEL
8 = BS
9 =
10 =
11 = VT
12 = FF
13 =
14 = SO
15 = SI
16 = DLE
17 = DC1
18 = DC2
19 = DC3
20 = DC4
21 = NAK
22 = SYN
23 = ETB
24 = CAN
25 = EM
26 = SUB
27 = ESC
28 = FS
29 = GS
30 = RS
31 = US
32 = Space
33 = !
34 = "
35 = #
36 = $
37 = %
38 = &
39 = '
40 = (
41 = )
42 = *
43 = +
44 = ,
45 = -
46 = .
47 = /
48 = 0
49 = 1
50 = 2
51 = 3
52 = 4
53 = 5
54 = 6
55 = 7
56 = 8
57 = 9
58 = :
59 = ;
60 = <
61 = =
62 = >
63 = ?
64 = @
65 = A
66 = B
67 = C
68 = D
69 = E
70 = F
71 = G
72 = H
73 = I
74 = J
75 = K
76 = L
77 = M
78 = N
79 = O
80 = P
81 = Q
82 = R
83 = S
84 = T
85 = U
86 = V
87 = W
88 = X
89 = Y
90 = Z
91 = [
92 = \
93 = ]
94 = ^
95 = _
96 = `
97 = a
98 = b
99 = c
100 = d
101 = e
102 = f
103 = g
104 = h
105 = i
106 = j
107 = k
108 = l
109 = m
110 = n
111 = o
112 = p
113 = q
114 = r
115 = s
116 = t
117 = u
118 = v
119 = w
120 = x
121 = y
122 = z
123 = {
124 = |
125 = }
126 = ~
127 = DEL
128 = PAD
129 = HOP
130 = BPH
131 = NBH
132 = IND
133 = NEL
134 = SSA
135 = ESA
136 = HTS
137 = HTJ
138 = LTS
139 = PLD
140 = PLU
141 = RI
142 = SS2
143 = SS3
144 = DCS
145 = PU1
146 = PU2
147 = STS
148 = CCH
149 = MW
150 = SPA
151 = EPA
152 = SOS
153 = SGCI
154 = SCI
155 = CSI
156 = ST
157 = OSC
158 = PM
159 = APC
160 = 
161 = Ą
162 = ˘
163 = Ł
164 = ¤
165 = Ľ
166 = Ś
167 = §
168 = ¨
169 = Š
170 = Ş
171 = Ť
172 = Ź
173) = SHY
174 = Ž
175 = Ż
176 = °
177 = ą
178 = ˛
179 = ł
180 = ´
181 = ľ
182 = ś
183 = ˇ
184 = ¸
185 = š
186 = ş
187 = ť
188 = ź
189 = ˝
190 = ž
191 = ż
192 = Ŕ
193 = Á 
194 = Â
195 = Ă
196 = Ä
197 = Ĺ
198 = Ć
199 = Ç
200 = Č
201 = É
202 = Ę
203 = Ë
204 = Ě
205 = Í
206 = Î
207 = Ď
208 = Đ
209 = Ń
210 = Ň
211 = Ó
212 = Ô
213 = Ő
214 = Ö
215 = ×
216 = Ř
217 = Ů
218 = Ú
219 = Ű
220 = Ü
221 = Ý
222 = Ţ
223 = ß
224 = ŕ
225 = á
226 = â
227 = ă
228 = ä
229 = ĺ
230 = ć
231 = ç
232 = č
233 = é
234 = ę
235 = ë
236 = ě
237 = í
238 = î
239 = ď
240 = đ
241 = ń
242 = ň
243 = ó
244 = ô
245 = ő
246 = ö
247 = ÷
248 = ř
249 = ů
250 = ú
251 = ű
252 = ü
253 = ý
254 = ţ
255 = ˙
UTF_8 minta:
ASCII
chr()
0 = 
1 = SOH
2 = STX
3 = ETX
4 = EOT
5 = ENQ
6 = ACK
7 = BEL
8 = BS
9 = 	
10 = 
11 = VT
12 = FF
13 = 
14 = SO
15 = SI
16 = DLE
17 = DC1
18 = DC2
19 = DC3
20 = DC4
21 = NAK
22 = SYN
23 = ETB
24 = CAN
25 = EM
26 = SUB
27 = ESC
28 = FS
29 = GS
30 = RS
31 = US
32 = Space 
33 = !
34 = "
35 = #
36 = $
37 = %
38 = &
39 = '
40 = (
41 = )
42 = *
43 = +
44 = ,
45 = -
46 = .
47 = /
48 = 0
49 = 1
50 = 2
51 = 3
52 = 4
53 = 5
54 = 6
55 = 7
56 = 8
57 = 9
58 = :
59 = ;
60 = <
61 = =
62 = >
63 = ?
64 = @
65 = A
66 = B
67 = C
68 = D
69 = E
70 = F
71 = G
72 = H
73 = I
74 = J
75 = K
76 = L
77 = M
78 = N
79 = O
80 = P
81 = Q
82 = R
83 = S
84 = T
85 = U
86 = V
87 = W
88 = X
89 = Y
90 = Z
91 = [
92 = \
93 = ]
94 = ^
95 = _
96 = `
97 = a
98 = b
99 = c
100 = d
101 = e
102 = f
103 = g
104 = h
105 = i
106 = j
107 = k
108 = l
109 = m
110 = n
111 = o
112 = p
113 = q
114 = r
115 = s
116 = t
117 = u
118 = v
119 = w
120 = x
121 = y
122 = z
123 = {
124 = |
125 = }
126 = ~
127 = DEL
128 = �
129 = � Á
130 = �
131 = �
132 = �
133 = �
134 = �
135 = �
136 = �
137 = � É
138 = �
139 = �
140 = �
141 = � Í
142 = �
143 = �
144 = � Ő
145 = � ő
146 = �
147 = � Ó
148 = �
149 = �
150 = � Ö
151 = �
152 = �
153 = �
154 = � Ú
155 = �
156 = � Ü
157 = �
158 = �
159 = �
160 = �
161 = � á
162 = �
163 = �
164 = �
165 = �
166 = �
167 = �
168 = �
169 = � é
170 = �
171 = �
172 = �
173 = � í
174 = �
175 = �
176 = � Ű
177 = � ű
178 = �
179 = � ó
180 = �
181 = �
182 = � ö
183 = �
184 = �
185 = �
186 = � ú
187 = �
188 = � ü
189 = �
190 = �
191 = �
192 = �
193 = �
194 = �
195 = � Összesít
196 = �
197 = � Összesít
198 = �
199 = �
200 = �
201 = �
202 = �
203 = �
204 = �
205 = �
206 = �
207 = �
208 = �
209 = �
210 = �
211 = �
212 = �
213 = �
214 = �
215 = �
216 = �
217 = �
218 = �
219 = �
220 = �
221 = �
222 = �
223 = �
224 = �
225 = �
226 = �
227 = �
228 = �
229 = �
230 = �
231 = �
232 = �
233 = �
234 = �
235 = �
236 = �
237 = �
238 = �
239 = �
240 = �
241 = �
242 = �
243 = �
244 = �
245 = �
246 = �
247 = �
248 = �
249 = �
250 = �
251 = �
252 = �
253 = �
254 = �
255 = �
Mód = 0
Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 0
    [4] => 0
    [5] => 0
    [6] => 0
    [7] => 0
    [8] => 0
    [9] => 0
    [10] => 0
    [11] => 0
    [12] => 0
    [13] => 0
    [14] => 0
    [15] => 0
    [16] => 0
    [17] => 0
    [18] => 0
    [19] => 0
    [20] => 0
    [21] => 0
    [22] => 0
    [23] => 0
    [24] => 0
    [25] => 0
    [26] => 0
    [27] => 0
    [28] => 0
    [29] => 0
    [30] => 0
    [31] => 0
    [32] => 4
    [33] => 1
    [34] => 0
    [35] => 0
    [36] => 0
    [37] => 0
    [38] => 0
    [39] => 0
    [40] => 0
    [41] => 0
    [42] => 0
    [43] => 0
    [44] => 0
    [45] => 0
    [46] => 1
    [47] => 0
    [48] => 0
    [49] => 0
    [50] => 0
    [51] => 0
    [52] => 0
    [53] => 0
    [54] => 0
    [55] => 0
    [56] => 0
    [57] => 0
    [58] => 1
    [59] => 0
    [60] => 0
    [61] => 0
    [62] => 0
    [63] => 0
    [64] => 0
    [65] => 0
    [66] => 0
    [67] => 0
    [68] => 0
    [69] => 0
    [70] => 0
    [71] => 0
    [72] => 1
    [73] => 0
    [74] => 0
    [75] => 0
    [76] => 0
    [77] => 0
    [78] => 0
    [79] => 0
    [80] => 0
    [81] => 0
    [82] => 0
    [83] => 0
    [84] => 0
    [85] => 0
    [86] => 0
    [87] => 1
    [88] => 0
    [89] => 0
    [90] => 0
    [91] => 0
    [92] => 0
    [93] => 0
    [94] => 0
    [95] => 0
    [96] => 0
    [97] => 0
    [98] => 1
    [99] => 0
    [100] => 1
    [101] => 5
    [102] => 0
    [103] => 0
    [104] => 0
    [105] => 0
    [106] => 0
    [107] => 2
    [108] => 3
    [109] => 0
    [110] => 0
    [111] => 2
    [112] => 0
    [113] => 0
    [114] => 1
    [115] => 1
    [116] => 2
    [117] => 0
    [118] => 0
    [119] => 0
    [120] => 0
    [121] => 0
    [122] => 1
    [123] => 0
    [124] => 0
    [125] => 0
    [126] => 0
    [127] => 0
    [128] => 0
    [129] => 0
    [130] => 0
    [131] => 0
    [132] => 0
    [133] => 0
    [134] => 0
    [135] => 0
    [136] => 0
    [137] => 1
    [138] => 0
    [139] => 0
    [140] => 0
    [141] => 0
    [142] => 0
    [143] => 0
    [144] => 0
    [145] => 1
    [146] => 0
    [147] => 0
    [148] => 0
    [149] => 0
    [150] => 0
    [151] => 0
    [152] => 0
    [153] => 0
    [154] => 0
    [155] => 0
    [156] => 0
    [157] => 0
    [158] => 0
    [159] => 0
    [160] => 0
    [161] => 1
    [162] => 0
    [163] => 0
    [164] => 0
    [165] => 0
    [166] => 0
    [167] => 0
    [168] => 0
    [169] => 1
    [170] => 0
    [171] => 0
    [172] => 0
    [173] => 1
    [174] => 0
    [175] => 0
    [176] => 0
    [177] => 2
    [178] => 0
    [179] => 1
    [180] => 0
    [181] => 0
    [182] => 1
    [183] => 0
    [184] => 0
    [185] => 0
    [186] => 1
    [187] => 0
    [188] => 1
    [189] => 0
    [190] => 0
    [191] => 0
    [192] => 0
    [193] => 0
    [194] => 0
    [195] => 8
    [196] => 0
    [197] => 3
    [198] => 0
    [199] => 0
    [200] => 0
    [201] => 0
    [202] => 0
    [203] => 0
    [204] => 0
    [205] => 0
    [206] => 0
    [207] => 0
    [208] => 0
    [209] => 0
    [210] => 0
    [211] => 0
    [212] => 0
    [213] => 0
    [214] => 0
    [215] => 0
    [216] => 0
    [217] => 0
    [218] => 0
    [219] => 0
    [220] => 0
    [221] => 0
    [222] => 0
    [223] => 0
    [224] => 0
    [225] => 0
    [226] => 0
    [227] => 0
    [228] => 0
    [229] => 0
    [230] => 0
    [231] => 0
    [232] => 0
    [233] => 0
    [234] => 0
    [235] => 0
    [236] => 0
    [237] => 0
    [238] => 0
    [239] => 0
    [240] => 0
    [241] => 0
    [242] => 0
    [243] => 0
    [244] => 0
    [245] => 0
    [246] => 0
    [247] => 0
    [248] => 0
    [249] => 0
    [250] => 0
    [251] => 0
    [252] => 0
    [253] => 0
    [254] => 0
    [255] => 0
)
Mód = 1
Array
(
    [32] => 4
    [33] => 1
    [46] => 1
    [58] => 1
    [72] => 1
    [87] => 1
    [98] => 1
    [100] => 1
    [101] => 5
    [107] => 2
    [108] => 3
    [111] => 2
    [114] => 1
    [115] => 1
    [116] => 2
    [122] => 1
    [137] => 1
    [145] => 1
    [161] => 1
    [169] => 1
    [173] => 1
    [177] => 2
    [179] => 1
    [182] => 1
    [186] => 1
    [188] => 1
    [195] => 8
    [197] => 3
)
Mód = 2
Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 0
    [4] => 0
    [5] => 0
    [6] => 0
    [7] => 0
    [8] => 0
    [9] => 0
    [10] => 0
    [11] => 0
    [12] => 0
    [13] => 0
    [14] => 0
    [15] => 0
    [16] => 0
    [17] => 0
    [18] => 0
    [19] => 0
    [20] => 0
    [21] => 0
    [22] => 0
    [23] => 0
    [24] => 0
    [25] => 0
    [26] => 0
    [27] => 0
    [28] => 0
    [29] => 0
    [30] => 0
    [31] => 0
    [34] => 0
    [35] => 0
    [36] => 0
    [37] => 0
    [38] => 0
    [39] => 0
    [40] => 0
    [41] => 0
    [42] => 0
    [43] => 0
    [44] => 0
    [45] => 0
    [47] => 0
    [48] => 0
    [49] => 0
    [50] => 0
    [51] => 0
    [52] => 0
    [53] => 0
    [54] => 0
    [55] => 0
    [56] => 0
    [57] => 0
    [59] => 0
    [60] => 0
    [61] => 0
    [62] => 0
    [63] => 0
    [64] => 0
    [65] => 0
    [66] => 0
    [67] => 0
    [68] => 0
    [69] => 0
    [70] => 0
    [71] => 0
    [73] => 0
    [74] => 0
    [75] => 0
    [76] => 0
    [77] => 0
    [78] => 0
    [79] => 0
    [80] => 0
    [81] => 0
    [82] => 0
    [83] => 0
    [84] => 0
    [85] => 0
    [86] => 0
    [88] => 0
    [89] => 0
    [90] => 0
    [91] => 0
    [92] => 0
    [93] => 0
    [94] => 0
    [95] => 0
    [96] => 0
    [97] => 0
    [99] => 0
    [102] => 0
    [103] => 0
    [104] => 0
    [105] => 0
    [106] => 0
    [109] => 0
    [110] => 0
    [112] => 0
    [113] => 0
    [117] => 0
    [118] => 0
    [119] => 0
    [120] => 0
    [121] => 0
    [123] => 0
    [124] => 0
    [125] => 0
    [126] => 0
    [127] => 0
    [128] => 0
    [129] => 0
    [130] => 0
    [131] => 0
    [132] => 0
    [133] => 0
    [134] => 0
    [135] => 0
    [136] => 0
    [138] => 0
    [139] => 0
    [140] => 0
    [141] => 0
    [142] => 0
    [143] => 0
    [144] => 0
    [146] => 0
    [147] => 0
    [148] => 0
    [149] => 0
    [150] => 0
    [151] => 0
    [152] => 0
    [153] => 0
    [154] => 0
    [155] => 0
    [156] => 0
    [157] => 0
    [158] => 0
    [159] => 0
    [160] => 0
    [162] => 0
    [163] => 0
    [164] => 0
    [165] => 0
    [166] => 0
    [167] => 0
    [168] => 0
    [170] => 0
    [171] => 0
    [172] => 0
    [174] => 0
    [175] => 0
    [176] => 0
    [178] => 0
    [180] => 0
    [181] => 0
    [183] => 0
    [184] => 0
    [185] => 0
    [187] => 0
    [189] => 0
    [190] => 0
    [191] => 0
    [192] => 0
    [193] => 0
    [194] => 0
    [196] => 0
    [198] => 0
    [199] => 0
    [200] => 0
    [201] => 0
    [202] => 0
    [203] => 0
    [204] => 0
    [205] => 0
    [206] => 0
    [207] => 0
    [208] => 0
    [209] => 0
    [210] => 0
    [211] => 0
    [212] => 0
    [213] => 0
    [214] => 0
    [215] => 0
    [216] => 0
    [217] => 0
    [218] => 0
    [219] => 0
    [220] => 0
    [221] => 0
    [222] => 0
    [223] => 0
    [224] => 0
    [225] => 0
    [226] => 0
    [227] => 0
    [228] => 0
    [229] => 0
    [230] => 0
    [231] => 0
    [232] => 0
    [233] => 0
    [234] => 0
    [235] => 0
    [236] => 0
    [237] => 0
    [238] => 0
    [239] => 0
    [240] => 0
    [241] => 0
    [242] => 0
    [243] => 0
    [244] => 0
    [245] => 0
    [246] => 0
    [247] => 0
    [248] => 0
    [249] => 0
    [250] => 0
    [251] => 0
    [252] => 0
    [253] => 0
    [254] => 0
    [255] => 0
)
Mód = 3
Az ékezeteseket
így jeleníti meg = �

!.:HWbdeklorstz
������������

Mód = 4
A sárga színnel jelőltek,
weboldalon
nem jelennek meg.

SOH STX ETX EOT ENQ ACK BEL
BS VT FF SO SI DLE DC1 DC3 DC4
NAK SYN ETB CAN EM SUB ESC
FS GS RS US

"#$%&'()*+,-/0123456789; <=>?@
ABCDEFGIJKLMNOPQRSTUVXYZ
[\]^_`acfghijmnpquvwxy{|}~
DEL
���������������
���������������
���������������
���������������
���������������
���������������
���������������
�����������