how can I replace the tabs in a file with a comma?

$contents = str_replace("\t", ",", $contents);

That doesn't seem to be working:

here's the file again:

200        Paddington        100        12.99        5.00        0.50        Our 11 inch bear is a great companion for those cold winter mornings. Quality construction, soft fur, and a red and white raglan tee will make him the envy of all your stuffed animals. \r\nSoft plush fur 11 inches tall.\r\nRed bow and t-shirt included.        1        1        graphics/00000001/bear.jpg        graphics/00000001/bear-lg.jpg
100        Bagels and Lox        200        10.00        10.00        1.00        This is the talking fish        1        1
300        Monkey Around        300        5.00        5.00        1.00        This is a talking monkey.        1        1
400        I Hate Miva Bear        100        12.50        1.00        0.75        This is the famous I hate Miva Bear         1        1

also...

when placing commas in a file like this so you can explode it, isn't there something you have to do so that the first of the array will be counted......

like str_replace("", ",", $contents);

or something like that?

    try this one:

    $newarray = preg_replace("/\t/", ",", $oldarray);

    don't understand what you mean by "so that the first of the array will be counted"
    please explain

      that doesn't seem to work either. here's the output in html:

      200 Paddington 100 12.99 5.00 0.50 Our 11 inch bear is a great companion for those cold winter mornings. Quality construction soft fur and a red and white raglan tee will make him the envy of all your stuffed animals. \r\nSoft plush fur 11 inches tall.\r\nRed bow and t-shirt included. 1 1 graphics/00000001/bear.jpg graphics/00000001/bear-lg.jpg 
      100 Bagels and Lox 200 10.00 10.00 1.00 This is the talking fish 1 1 
      300 Monkey Around 300 5.00 5.00 1.00 This is a talking monkey. 1 1 
      400 I Hate Miva Bear 100 12.50 1.00 0.75 This is the famous I hate Miva Bear 1 1 
      

      What I mean is.... well, what is the ^ for in a preg_replace statment or something. I thought I read somewhere that it is so the first object will be read in a sentence of something like that? Not sure, but nevermind on that if you can figure out what's up with the tabs.

        Eh...

        $string = preg_replace('#\t#', ',', $string);

        Seems to be the same thing ir4z0r said, though.

          yeah. I think I got it!

          since a tab is eight spaces I did this:

          $contents = str_replace("        ", ",", $contents);
          

          and it seems to be working. That was one of those.....dooope! 😃

            Yeah, I suppose ours wouldn't have worked if what it was really searching for was spaces.

              Write a Reply...