PHP/String/count chars — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 07:07, 26 мая 2010
count_chars.php
<?php
$sentence = "this is a test";
$chart = count_chars($sentence, 1);
foreach($chart as $letter=>$frequency)
echo "Character ".chr($letter)." appears $frequency times<br />";
?>
mixed count_chars ( string str [, int mode] ) returns an array containing the letters used in that string and how many times each letter was used.
<?
$str = "This is a test, only a test, and nothing but a test.";
$a = count_chars($str, 1);
print_r($a);
?>