Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2003
    Posts
    262
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Srting Manipulation / Formatting

    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?

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    PHP Code:
    1 function fits all (well most)
    <?
    echo substr('Hi There' ,0) ;
    echo 
    substr('Hi There' , -) ;
    echo 
    substr('Hi There' ) ;
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    Regular Coder
    Join Date
    Jul 2003
    Posts
    262
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

    Ciao.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •