我有一个变量发布到另一个页面,当回显时,它看起来像
Acme, Upgrade Site, Kansas
我想用逗号分隔那些并分配3变量,如
$Company = ‘Acme’;
$Action = ‘Upgrade Site’;
$Location = ‘Kansas’;”
答案 0 :(得分:1)
$str= 'Acme, Upgrade Site, Kansas' ;
$arr = explode(',',$str);
$Company = $arr[0];
$Action = $arr[1];
$Location = $arr[2];
试
答案 1 :(得分:0)
所以我认为最好的选择可能就是使用explode
:
// Assume $inputString is your input
$explodedInput = explode(",", $inputString);
// Now, $explodedInput[0] will be Company,
// $explodedInput[1] will be "Upgrade Site", etc...
$Company = $explodedInput[0] //...