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 6 of 6

Thread: PHP Explode

  1. #1
    New Coder
    Join Date
    Mar 2005
    Location
    UK
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts

    PHP Explode

    I have this code:
    PHP Code:
    <?php
    $handle 
    fopen("info.csv""r");
    $data fgetcsv($handle1000";");
    $data2 explode(","$data);
    echo 
    $data2[0]; // piece1
    echo $data2[1]; // piece2
    ?>
    It gets a csv file and then what i want it to do is explode it into several variables.

    I cannot get it to work. When i preview it all i get is "Array" on the page.

    Am i doing something wrong?
    Andrew,
    AKA ItsMe

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    356
    Thanks
    0
    Thanked 16 Times in 16 Posts
    Should the semi colon (;) on the line below be a comma (,)
    PHP Code:
    $data fgetcsv($handle1000";"); 
    Further info; http://php.net/manual/en/function.fgetcsv.php

  • #3
    New Coder
    Join Date
    Mar 2005
    Location
    UK
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It loads the data ok, but i cant explode it.
    Andrew,
    AKA ItsMe

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Posts
    356
    Thanks
    0
    Thanked 16 Times in 16 Posts
    if ; is the delimiter, shouldn't you be exploding on the same delimiter?

  • #5
    Banned
    Join Date
    Nov 2002
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts
    use the delimiter quantifier to prepend your variable

  • #6
    New Coder
    Join Date
    Mar 2005
    Location
    UK
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the help guys. I have solved the prob now.
    Andrew,
    AKA ItsMe


  •  

    Posting Permissions

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