I have strings like this:
$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"';
I tried to separate the string and turn it into an array like this:
$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"';
...
*/
I want to explode the string when there is /
only, but when it meets \/
it shouldn't explode the string, my code still explode the string if it contains \/
, is there a way to do this?