SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: String to array

  1. #1
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)

    String to array

    How might I convert a url (ex. /test1/test2/test3) to be in an array as array("test1", "test2", "test3") using the / as a seperator.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,192
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    PHP Code:
    echo '<pre>',print_rexplode('/'trim('/test1/test2/test3','/') ) ),'</pre>'
    The only code I hate more than my own is everyone else's.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, implode does the opposite (converts an array to a string separated by the character of your choice).
    Martin.


Bookmarks

Posting Permissions

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