我有这样的字符串:
$string1 = '35 Hose & Couplings/350902 GARDEN HOSE COUPLING, PVC, 16\/19 MM"';
$string2 = '35 Hose & Couplings/350904 GARDEN HOSE TAP CONNECTOR, PVC, 3\/4" FEMALE THREAD"';
我试着把字符串分开,然后把它变成这样的数组:
$name1 = explode('/', $string1);
$name1 = trim(end($name1));
$name2 = explode('/', $string2);
$name2 = trim(end($name2));
/*
#results
$name1[0] = '35 Hose & Couplings';
$name1[1] = '350902 GARDEN HOSE COUPLING, PVC, 16\';
$name1[2] = '19 MM"';
...
#expected results
$name1[0] = '35 Hose & Couplings';
$name1[1] = '350902 GARDEN HOSE COUPLING, PVC, 16\/19 MM"';
...
*/
我想在只有 /
时分解字符串,但是当它遇到 \/
时,它不应该/strong> 分解字符串,如果它包含 \/
我的代码仍然分解字符串,有没有办法做到这一点?
最佳答案
关于Php字符串根据字符与字符串条件匹配来分解字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48986634/