Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
adding double quotes to csv
  • when i use 
    $output = Format::forge()->to_csv($data, ', ');

    it adds additional quotes...is there a trick or something to do with the format of $data being converted to csv...please help!
  • What do you mean with "additional quotes"?
  • What is the input array? Any quotes in there? And what is your format config? And which version of Fuel?
  • input array is \DB::select()->execute->as_array(),format config is default,fuel is 1.6
  • HarroHarro
    Accepted Answer
    Works fine here, must be at your end somewhere. Just ran this in 1.6:

    $result = \DB::select()->from('groups')->execute()->as_array();
    var_dump($result);
    $result = \Format::forge()->to_csv($result, ',');
    var_dump($result);

    Results:

    array (size=2)
      0 =>
        array (size=2)
          'id' => string '1' (length=1)
          'name' => string 'Group 1' (length=7)
      1 =>
        array (size=2)
          'id' => string '2' (length=1)
          'name' => string 'Group 2' (length=7)

    string '"id","name"
    "1","Group 1"
    "2","Group 2"' (length=39)

  • ok thank you

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion