|
-
May 28th, 2005, 04:46 AM
#1
Thread Starter
Addicted Member
To read the specified character
hi,
what is the PHP function to read the specified character -given its position in the string- in a string variable(just like Instr() function in VB)?
thanks in advance
"Quis custodiet ipsos custodes?"
Juvenal
Mete the Hun wanted to live in peace with the Chinese. So he gave the Chinese Emperor his favorite horse, best swords in his armory, and lots of other cool stuff. But then the Chinese Emperor asked for one thing. A useless land through the north. It was a small, useless, unproductive, uninhabited piece of land. But Mete the Hun's answer was certain:
I gave you horses, weapons and much more which belonged to me. But the lands are not mine, it's my nation's and I'm ready to fight, kill and die for just an inch my country
-=Joey Jordison R0CKS!! =-
-
May 28th, 2005, 06:36 AM
#2
Lively Member
Re: To read the specified character
[code]
$twister = "peter picked a peck of pickeled peppers";
print(strpos($twister,"peck");
// this will print the position of peck in the string $twister
[code]
HTH
Jobs: "Do u want to sell colored sugar water or change the world?"
Get Firefox Now!!!
Mendhak leaving town. 
-
May 28th, 2005, 10:30 AM
#3
Thread Starter
Addicted Member
Re: To read the specified character
well that's not the one I'm looking for,but that's my fault, I wasn't clear enough. I want the function to read the character at the given position. The character is not known.
e.g
$string="What a beautiful day"
echo functioniwant($string,2)
----------------------------------
The result should be "h".
"Quis custodiet ipsos custodes?"
Juvenal
Mete the Hun wanted to live in peace with the Chinese. So he gave the Chinese Emperor his favorite horse, best swords in his armory, and lots of other cool stuff. But then the Chinese Emperor asked for one thing. A useless land through the north. It was a small, useless, unproductive, uninhabited piece of land. But Mete the Hun's answer was certain:
I gave you horses, weapons and much more which belonged to me. But the lands are not mine, it's my nation's and I'm ready to fight, kill and die for just an inch my country
-=Joey Jordison R0CKS!! =-
-
May 28th, 2005, 10:41 AM
#4
Re: To read the specified character
I think the function you want is substr() 
Or, you can just do this:
String${Character_Number_Here}
Both will return the character 
Cheers,
RyanJ
-
May 28th, 2005, 10:59 AM
#5
Thread Starter
Addicted Member
Re: To read the specified character
"Quis custodiet ipsos custodes?"
Juvenal
Mete the Hun wanted to live in peace with the Chinese. So he gave the Chinese Emperor his favorite horse, best swords in his armory, and lots of other cool stuff. But then the Chinese Emperor asked for one thing. A useless land through the north. It was a small, useless, unproductive, uninhabited piece of land. But Mete the Hun's answer was certain:
I gave you horses, weapons and much more which belonged to me. But the lands are not mine, it's my nation's and I'm ready to fight, kill and die for just an inch my country
-=Joey Jordison R0CKS!! =-
-
May 28th, 2005, 11:02 AM
#6
Re: To read the specified character
 Originally Posted by kill_bill_gates
thanks sciguyryan
You are welcome 
Just remmber if your thread has been solved edit the original post and add [Resolved] to its title and the green checkmark as its icon 
Cheers,
RyanJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|