SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Striping a comma from a csv file

    I have a csv file where i need to strip the comma deliminator
    from $BN and join its contents to $address.


    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
    {
    $customerid = $data[0];
    $cust = $data[1];
    // BN
    $BN = $data[2];
    // Address
    $address = $data[3];

    What is the best way to go about this?

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    everywhere
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure I understood the question but it sounds like you want to concatenate the $BN with $address

    PHP Code:
    while ( ($data fgetcsv$handle1000 )) !== FALSE )
    {
        list ( 
    $customerid$cust$BN$address ) = $data;
        
    $joined $BN $address;

    The 3rd argument to fgetcsv defaults to a comma so you do not need to supply it.
    Webmobo - Open Source News Scripts
    Portfolio / Blog


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
  •