OK, one more problem and then I think my function will work.
Right now, my second function is just reporting the character length back next to the string like so:
string(20) "testing testing nice"
is there anyway to change the format of that return? And what do I need to change to get the WORD count too?
Is it even possible to make the format look like this:
string word count: 3 character count: 20 "testing testing nice"
thanks
file1.php
<?php
require('myfunctions.php');
if($_POST) {
$result = phptest($_POST['input']);
if ($result === false) {
echo 'No mean words were found.';
} else {
var_dump($result);
}
}
?>
<?php
echo "<br/> Sum function: ".sum(1,2,3,4)."<br/>";
echo "Average function: ".average(1,2,3,4)."<br/>";
?>
<form action="" method="post">
<input name="input" type="text" size="20" maxlength="20" />
<input name="submit" type="submit" value="submit" />
</form>
myfunctions.php
<?php
function sum() {
return array_sum(func_get_args());
}
function average() {
$args = func_num_args();
if ($args == 0) {
return 0;
}
return array_sum(func_get_args()) / $args;
}
?>
<?php
function phptest($input) {
$search = array('ugly', 'rude');
$replace = array('nice', 'sweet');
$output = str_ireplace($search, $replace, $input, $replace_count);
if ($replace_count === 0) {
return false;
} else {
return $output;
}
}
?>
var_dumpsomewhere? That is for debugging and no, you can't change that format. But you can make your own output.var_dumping the returned value and wants to reformat what var_dump gives