<?php
class paragraph {
private $str="";
function paragraph($str) {
$this->str = $str;
}
function count_words() {
return sizeof(explode(" ",$this->str));
}
function count_chars() {
return strlen($this->str);
}
function count_ints() {
$i=0;
foreach(str_split($this->str) as $key => $value) {
if(is_numeric($value)) $i++;
}
return $i;
}
function str_type() {
if(is_string($this->str)) return "string";
elseif(is_int($this->str)) return "int";
elseif(is_numeric($this->str)) return "numeric";
elseif(is_float($this->str)) return "floar";
else return false;
}
function cap_letter($letter=0) {
$str = str_split($this->str);
if($letter<=sizeof($str)) {
if(strtoupper($str[$letter])) {
$this->str = implode($str);
return $this->str;
}
else {
return false;
}
}
else {
return false;
}
}
function get_chars($str) {
$str = str_split($str);
$chars = array();
foreach($str as $key1 => $value1) {
foreach($chars as $key2 => $value2) {
if($value1!=$value2) {
$chars[] = $value1;
}
}
}
return $chars;
}
}
?>