|
-
Jul 7th, 2006, 08:06 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Left & Right
Hello
I set a string "abcdefg".
How can I return a string containing a specified number of characters from the left or right side of the string I set?
Example:
If I want to return 3 characters from the left of the string above, it'll print "abc".
In VB6, I can do that by "Left$(str,Length)" or "Right$(str,Length)".
Thanks
-
Jul 7th, 2006, 08:08 PM
#2
Re: Left & Right
Use the SubStr function.
Check out the exmples below.
PHP Code:
echo substr('abcdef', 1); // bcdef
echo substr('abcdef', 1, 3); // bcd
echo substr('abcdef', 0, 4); // abcd
echo substr('abcdef', 0, 8); // abcdef
echo substr('abcdef', -1, 1); // f
-
Jul 7th, 2006, 10:15 PM
#3
Thread Starter
Addicted Member
Re: [RESOLVED] Left & Right
Thank you very much for helping.
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
|