我需要用逗号替换一个简单的文本来编号。
CSV File:
Test1
Test1, Test2
Test1, Test2, Test3
php代码
$text = "Test1";
$text1 = "Test1, Test2";
$text1 = "Test1, Test2, Test3";
$search = array('$text','$text1','$text2');
$replace = array('10','11','12');
$result = str_replace($search, $replace, $file);
echo "$result";
结果是: "10","10, 11","10, 11, 12"
但我想得到“10”、“11”、“12”。
这是最终脚本,但其中一个我得到“10、12”
$text1 = "Test1";
$text2 = "Test2";
$text3 = "Test3";
$text4 = "Test1, Test2, Test3";
$text5 = "Test1, Test2";
$text6 = "Test1, Test3";
$text7 = "Test2, Test3";
$text8 = "Blank";
array($text8,$text7,$text6,$text5,$text4,$text3,$text2,$text1);
array('10','11','12','13','14','15','16','17');