ord()

We can get the ASCII value of any character by using ord() function. Here is an example

echo ord('&');

The output is here

38

Using ASCII value we can get the character by using chr() string function
We can display a table by using for loop to get all the chars and its ASCII value like this.

$i=0;
echo "<table><tr><td>";
for($i==0;$i<=127;$i++){
echo " chr($i) = ".chr($i). " - ". ord(chr($i))."<br>";
if($i%40 == 0 and $i>39){echo "</td><td valign=top>";}
}
echo "</td></table>";

The output is here
chr(0) = - 0
chr(1) =  - 1
chr(2) =  - 2
chr(3) =  - 3
chr(4) =  - 4
chr(5) =  - 5
chr(6) =  - 6
chr(7) =  - 7
chr(8) =  - 8
chr(9) = - 9
chr(10) = - 10
chr(11) = - 11
chr(12) = - 12
chr(13) = - 13
chr(14) =  - 14
chr(15) =  - 15
chr(16) =  - 16
chr(17) =  - 17
chr(18) =  - 18
chr(19) =  - 19
chr(20) =  - 20
chr(21) =  - 21
chr(22) =  - 22
chr(23) =  - 23
chr(24) =  - 24
chr(25) =  - 25
chr(26) =  - 26
chr(27) =  - 27
chr(28) =  - 28
chr(29) =  - 29
chr(30) =  - 30
chr(31) =  - 31
chr(32) = - 32
chr(33) = ! - 33
chr(34) = " - 34
chr(35) = # - 35
chr(36) = $ - 36
chr(37) = % - 37
chr(38) = & - 38
chr(39) = ' - 39
chr(40) = ( - 40
chr(41) = ) - 41
chr(42) = * - 42
chr(43) = + - 43
chr(44) = , - 44
chr(45) = - - 45
chr(46) = . - 46
chr(47) = / - 47
chr(48) = 0 - 48
chr(49) = 1 - 49
chr(50) = 2 - 50
chr(51) = 3 - 51
chr(52) = 4 - 52
chr(53) = 5 - 53
chr(54) = 6 - 54
chr(55) = 7 - 55
chr(56) = 8 - 56
chr(57) = 9 - 57
chr(58) = : - 58
chr(59) = ; - 59
chr(60) = < - 60
chr(61) = = - 61
chr(62) = > - 62
chr(63) = ? - 63
chr(64) = @ - 64
chr(65) = A - 65
chr(66) = B - 66
chr(67) = C - 67
chr(68) = D - 68
chr(69) = E - 69
chr(70) = F - 70
chr(71) = G - 71
chr(72) = H - 72
chr(73) = I - 73
chr(74) = J - 74
chr(75) = K - 75
chr(76) = L - 76
chr(77) = M - 77
chr(78) = N - 78
chr(79) = O - 79
chr(80) = P - 80
chr(81) = Q - 81
chr(82) = R - 82
chr(83) = S - 83
chr(84) = T - 84
chr(85) = U - 85
chr(86) = V - 86
chr(87) = W - 87
chr(88) = X - 88
chr(89) = Y - 89
chr(90) = Z - 90
chr(91) = [ - 91
chr(92) = \ - 92
chr(93) = ] - 93
chr(94) = ^ - 94
chr(95) = _ - 95
chr(96) = ` - 96
chr(97) = a - 97
chr(98) = b - 98
chr(99) = c - 99
chr(100) = d - 100
chr(101) = e - 101
chr(102) = f - 102
chr(103) = g - 103
chr(104) = h - 104
chr(105) = i - 105
chr(106) = j - 106
chr(107) = k - 107
chr(108) = l - 108
chr(109) = m - 109
chr(110) = n - 110
chr(111) = o - 111
chr(112) = p - 112
chr(113) = q - 113
chr(114) = r - 114
chr(115) = s - 115
chr(116) = t - 116
chr(117) = u - 117
chr(118) = v - 118
chr(119) = w - 119
chr(120) = x - 120
chr(121) = y - 121
chr(122) = z - 122
chr(123) = { - 123
chr(124) = | - 124
chr(125) = } - 125
chr(126) = ~ - 126
chr(127) =  - 127

Be the first to post comment on this article :


Google+
PHP String Functions

Post Comment This is for short comments only. Use the forum for more discussions.






OPINION POLL

What is the most important factor of a web site
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2015 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer