Convert a single column of values into a comma seperated list - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Convert a single column of values into a comma seperated list (/showthread.php?tid=11748) Pages:
1
2
|
Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]johnwbaxter[/eluser] My second question of the day, this can't be good! I've got a csv with one column of values that i've uploaded and put into a variable. The problem is that the values are seperated by a new line char or something (csv generated by MS Excel) and i need to make the list comma seperated. Any ideas?! Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]Unknown[/eluser] Read file and replace new line char with comma? Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]johnwbaxter[/eluser] Yep! Edit - I've tried "\n" as the delimiter but no joy. Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]xwero[/eluser] the php function file gets the file content in an array so if you only have one column you can do Code: $lines = file($file); Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]johnwbaxter[/eluser] Hmm that does not seem to work unfortunately. What i've got thus far is (with your help from another post!): Code: $temp_csv = $_FILES['userfile']['tmp_name']; Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]xwero[/eluser] So you get an array with one value if i understand you correct? Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]johnwbaxter[/eluser] Yeah looks that way. Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]xwero[/eluser] But you see in your csv file that the values are on different lines? Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]johnwbaxter[/eluser] They are yes. Would it be helpful if i sent you the csv in question? Convert a single column of values into a comma seperated list - El Forum - 09-22-2008 [eluser]xwero[/eluser] It's strange that you don't get an array with multiple values then, the problem with line breaks for the file function is only when it's a mac file. Maybe the fault is in the fact that the file isn't read. what do you get when you var_dump the $lines variable? |