Revision: 51534
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 27, 2011 22:25 by vagrantradio
Initial Code
<?php $f = "test.txt"; // get string $str = file_get_contents($f); // count characters $numChar = strlen($str); echo "This file has ". $numChar . " character(s)"; // count characters without spaces $str2 = ereg_replace('[[:space:]]+', '', $str); $numChar = strlen($str2); echo "This file has ". $numChar . " character(s) without spaces"; // count words $numWords = str_word_count($str); echo "This file has ". $numWords . " words"; ?>
Initial URL
Initial Description
Initial Title
Counting Characters in PHP
Initial Tags
Initial Language
PHP