View Full Version : Srting Manipulation / Formatting

04-13-2004, 04:28 AM
I do a lot of VB programming where we have string manipulation functions like Left$, Right$, Mid$. For those who aren't familiar with the above functions they are pretty simple:

Left$("Hi There",2) = "Hi"
Right$("Hi There",5) = "There"
Mid$("Hi There",3,2) = "Th"

Does PHP have an equivalent to these?

04-13-2004, 04:47 AM
Not sure what that's meant to do. Can you explain? I know raf will come along and answer it for you soon, but would still like to understand what that code does ;)

04-13-2004, 04:57 AM
1 function fits all (well most)
echo substr('Hi There' ,0, 2 ) ;
echo substr('Hi There' , -5 ) ;
echo substr('Hi There' , 3 , 2 ) ;

04-13-2004, 05:09 AM
Ahh, If I was much of a C programmer I would have known that. Thanks!

NightFire - it just provides a way to manipulate strings; for example if I wanted to remove the file extension from a file name (vb code below):

s = "readme.txt"
s = Left$(s, Len(s) - 4)

... there are a lot of uses depending on what you want to do.