PHP 字串切割(拆解/分割)函數 (preg_split / explode)
PHP 字串切割(拆解/分割)函數 (preg_split / explode)
資料來源:https://github.com/jash-git/TW_save_stock-windows_cmd-
$csvData = file_get_contents(‘https://github.com/jash-git/TW_save_stock-windows_cmd-/blob/master/stock.csv?raw=true’, true);
$lines = preg_split(‘/\n|\r\n?/’, $csvData);//字串換行 分割(切割)
foreach ($lines as $line)
{
$data=explode(‘,’, $line);//PHP 字串切割
print_r($datas);//PHP 印出陣列
}