Help me on string functions
Posted: Sun May 21, 2006 4:35 pm
I am having problems with some strings functions;
strpos()
strstr()
strrpos()
substr()
strcmp()
When they are been executed from my local server but haventh been tested with a shared hosting, the result desplayed on my browser is;
Warning: Wrong parameter count for substr()
BELOW is a sample of the code i wrote to test the string functions
<?
$short = "This string Has 29 Characters";
for($i = 0; $i < strlen($short); $i++){
printf($short{$i});
}
$sts = "s";
print("The position of $sts in $short is:". strpos($short. $sts));
print("Result of looking for $sts". strstr($short. $sts));
echo substr("dkfhs fsd fkdhf sdfkds fsd sd sdhf sdhf sdfsdf" . 12 . 24);
?>
AND below was the result desplayed in my browser
This string Has 29 Characters
Warning: Wrong parameter count for strpos() in E:\Softwares\xampplite\htdocs\test\str.php on line 10
The position of s in This string Has 29 Characters is:
Warning: Wrong parameter count for strstr() in E:\Softwares\xampplite\htdocs\test\str.php on line 11
Result of looking for s
Warning: Wrong parameter count for substr() in E:\Softwares\xampplite\htdocs\test\str.php on line 12
So I want sombody to help me in this as in where I go wrong.
strpos()
strstr()
strrpos()
substr()
strcmp()
When they are been executed from my local server but haventh been tested with a shared hosting, the result desplayed on my browser is;
Warning: Wrong parameter count for substr()
BELOW is a sample of the code i wrote to test the string functions
<?
$short = "This string Has 29 Characters";
for($i = 0; $i < strlen($short); $i++){
printf($short{$i});
}
$sts = "s";
print("The position of $sts in $short is:". strpos($short. $sts));
print("Result of looking for $sts". strstr($short. $sts));
echo substr("dkfhs fsd fkdhf sdfkds fsd sd sdhf sdhf sdfsdf" . 12 . 24);
?>
AND below was the result desplayed in my browser
This string Has 29 Characters
Warning: Wrong parameter count for strpos() in E:\Softwares\xampplite\htdocs\test\str.php on line 10
The position of s in This string Has 29 Characters is:
Warning: Wrong parameter count for strstr() in E:\Softwares\xampplite\htdocs\test\str.php on line 11
Result of looking for s
Warning: Wrong parameter count for substr() in E:\Softwares\xampplite\htdocs\test\str.php on line 12
So I want sombody to help me in this as in where I go wrong.