i am trying to build a comma delimited string from a query so that i can insert it into a file. the resulting array from my query is $result_array. i have seemingly tried every variation of concatentation i can think of. none of them work so i obviously haven't found the right one yet. anybody got a suggestion? this should build a string with - a,b,c,d,e,f with a line feed carriage return at the end. here's the last try which doesn't work either. i've tried enclosing the whole thing in quotes and escaping out the "'s. i can get it to work with one element of the array only. as soon as i try to get the commas between the elements is where i am running into a problem. i am getting a parse error...

$output_csv .= $result_array["outlet_name"].,. $result_array[\"outlet_address\"].,. $result_array[\"outlet_city\"].,. $result_array[\"outlet_state\"].,. $result_array[\"outlet_zip\"].,. $result_array[\"taxpayer_name\"]\n";

    the commas have to be in quotes or PHP will think it's supposed to do something with them. Also, if you need to use $something['something'] notation within a string, put it in {}. Try the following, and you won't even need the concatenation operator:

    $output_csv = ""; //Blank out the string, just for good measure

    $output_csv .= "{$result_array['outlet_name']},{$result_array['outlet_address']},{$result_array['outlet_city']},{$result_array['outlet_state']},{$result_array['outlet_zip']},{$result_array['taxpayer_name']}\n";

    (Note: the messageboard messed up the formatting, put that all on one line)

    -Jim Keller
    http://ww.centerfuse.net

      yep, that does the trick. i tried about 4 or 5 different ways but the { }'s are what solved the problem.

      many, many thanks for your help!!

      btw, you are missing one w in the www in your signature. gets a broken link the way it is...thanks again.

        Write a Reply...