-1

我有一个变量发布到另一个页面,当回显时,它看起来像

Acme, Upgrade Site, Kansas 

我想用逗号分隔它们并分配 3 个变量,例如

$Company = ‘Acme’; 
$Action = ‘Upgrade Site’; 
$Location = ‘Kansas’;” 
4

2 回答 2

1
$str= 'Acme, Upgrade Site, Kansas' ;
$arr = explode(',',$str); 

$Company = $arr[0]; 
$Action = $arr[1]; 
$Location = $arr[2];

尝试

于 2013-10-25T16:55:16.157 回答
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] //...
于 2013-10-25T16:54:11.023 回答