Results 1 to 5 of 5

Thread: List break-down

  1. #1
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default List break-down

    I was wondering if there was a function that could identify components of a comma-seperated list (or any character for seperation--doesn't have to be a comma) and make an array out of them?

    So it would basically change "12,15,1,4,7,322,41" and convert it to "array[0] = 12; array[1] = 15; array[2] = 1..."

    I looked through PHP.net, but I don't know the proper name for the technique (I thought it might be parsing, but evidently not?) so it wasn't much help.

    Thanks,
    Mob1us

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    $new_array = explode("character",$string);
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by boxxertrumps View Post
    $new_array = explode("character",$string);
    Where "character" would, in this case, be ','.
    Mike

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    and then after you do what you want with the "array" you can convert it back to a string by

    PHP Code:
    $tring implode(delimiter$new_array); 
    usually a good re-delimiter is a blank space " " or a comma - space ", "

  5. #5
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks a lot. Also, I was looking at the explode() function and was thinking of making a sort of webspider. I was wondering if there was a way to capture all text between certain HTML tags (for instance, I'd want all data between <td id="data"> and </td>, or something to that effect).

    Also, for that same project, can fopen() and fread() successfully open pages that are the result of a query string? For instance, could I read the HTML output by the following URL just as if it were an actual hand-typed HTML file?: http://sample.com/index.php?step=die_in_fire

    I appreciate your help.

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
  •