我试图像这样爆炸多个字符串:
$str1 = 'Apple\'s OS and the "Microsoft OS", ----- any text with quotes & symbols ---- ';
$str2 = 'Sony\'s Laptop and the "Toshiba\'s"';
$string = "".$str1.",".$str2."";
$result = explode(',',$string);
echo "Str1 : ".$result[0]."<br/>";
echo "Str2 : ".$result[1]."<br/>";
但是我得到了这个输出:
Str1 : Apple's OS and the "Microsoft OS"
Str2 : ----- any text with quotes & symbols ---- //This Str2 actually is the part of Str1
我想要这个输出 - &gt;
`Str1 : Apple's OS and the "Microsoft OS, ----- any text with quotes & symbols ----
Str2 : Sony's Laptop and the "Toshiba's"`
请帮忙。
答案 0 :(得分:1)
这是一个能够做到这一点的功能
function implodeStrings(...$array) {
$output = [];
foreach($array as $str) {
$output[] = $str;
}
return $output;
}