PHP/Data Type/Char

Материал из Web эксперт
Версия от 07:03, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Predefined Characters and Classes

Character Meaning
\a        Beep
\n        Newline character
\r        Carriage return
\t        Tab
\f        Formfeed
\e        Escape
\d        Digit (same as [0-9])
\D        Nondigit character (same as [^0-9])
\w        Word character (same as [a-zA-Z0-9_])
\W        Nonword character
\s        White-space character (same as [ \t\n\r\f])
\S        Non White-space character
\xX       Hexadecimal digit
\cX       Matches the corresponding control character



String char count

<?
$twister = "Peter Piper picked a peck of pickled peppers";
print("$twister<BR>");
$letter_array = count_chars($twister, 1);
while ($cell = each($letter_array)){
  $letter = chr($cell["key"]);
  $frequency = $cell["value"];
  print("Character: "$letter"; frequency:  $frequency<BR>");
}
?>