php common string functions summary

1. str_getcsv  parse string array csv

parameter:

input  string to be parsed

delimiter  setting field delimiter (only a single character)

enclosure  set wrapped character field (only a single character)

escape  Set the escape character (a single character only), the default is a backslash (\)

str = $ " China, Guangdong Province, Guangzhou City, Tianhe District, '113.329884,23.154799', 1, '2016-01-01 12:00:00', '1,2,3,4,5,6' " ;
$arr = str_getcsv($str, ',', "'");
print_r($arr);

Output:

Array
(
  [0] => Chinese
  [1] => Guangdong Province
  [2] => Guangzhou
  [3] => Tianhe
  [4] => 113.329884,23.154799
  [5] => 1
  [6] => 2016-01-01 12:00:00
  [7] => 1,2,3,4,5,6
)

  

Guess you like

Origin www.cnblogs.com/zxqblogrecord/p/11941672.html