Results 1 to 2 of 2

Thread: Parsing Data

  1. #1

    Thread Starter
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209

    Parsing Data

    Let's say I have data that's something like this:

    title:author:title2:autor2:title3:author3

    How would I seperate it to have a database table populated with the authors in one column and its corresponding title in another?

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    PHP Code:
    $stuff "title:author:title2:autor2:title3:author3";
    $info explode(":"$stuff);
    $count count($info);

    for (
    $i 0$i $count$i++) {
      if (
    even($info[$i] == 1) {
        echo 
    $info[$i];
      } else {
        echo 
    " - " $info[$i] . "<br>\n";
      }
    }


    function 
    even($var) {
        return (
    $var == 0);

    This is how I'd do it. Although I ran that off the top of my head, it should work.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width