-3

in PHP I am reading a text file with many lines, where each $line have the format: text1,text2,text3,.. so, i am reading with fgets() each line, but i dont know how to assign each variable of the line like $text1 = text1, $text2=text2, etc.. Any help? thanks in advance

West14
  • 27
  • 4
  • 1
    take a look at the 'explode' function [here](http://php.net/manual/en/function.explode.php). – ethrbunny Nov 12 '14 at 18:41
  • possible duplicate of [How can I split a comma delimited string into an array in PHP?](http://stackoverflow.com/questions/1125730/how-can-i-split-a-comma-delimited-string-into-an-array-in-php) – andy Nov 12 '14 at 18:43
  • thanks! explode is working fine! – West14 Nov 12 '14 at 22:17

1 Answers1

0

Just use fgetcsv(). Details here. This will pull each line of the file and split the content into an array minus the commas.

DevDonkey
  • 4,835
  • 2
  • 27
  • 41