0

I have this string:

$myString = "toto;titi;tata;;;;tutu;;tyty";

I wish with : explode(';', $myString);

["toto","titi","tata","","","","tutu","","tyty"]

but i have :

$result = ["toto","titi","tata","tutu","tyty"];

I lose the values ​​empty chains, I want to keep them.

I do not know how to do it, someone would have a solution plz ?

skyhol
  • 1
  • 1
    Have you tried: http://php.net/manual/en/function.str-getcsv.php – KIKO Software Apr 23 '17 at 09:54
  • Use [`fgetcsv`](http://php.net/fgetcsv]) function please. – u_mulder Apr 23 '17 at 09:54
  • 1
    what do I do incorrect ? - https://eval.in/781080 – splash58 Apr 23 '17 at 09:54
  • @splash58: Good point, it gives the same result as `str_getcsv()`. Nevertheless, you should use `str_getcsv()` when it is a line from a CSV file. – KIKO Software Apr 23 '17 at 09:59
  • 1
    Already answered [http://stackoverflow.com/questions/64570/explode-that-doesnt-return-empty-strings](http://stackoverflow.com/questions/64570/explode-that-doesnt-return-empty-strings) I didn't tried the solution. – Robert Apr 23 '17 at 10:10

0 Answers0