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.
Help me on string functions
Moderator: General Moderators
your periods in between the parameters on your str* calls should be commas.
That is:
That is:
Code: Select all
<?
$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);
?> -
magosla2001
- Forum Newbie
- Posts: 20
- Joined: Sat May 20, 2006 8:54 am