这是我如何构建字符串并将其分配给变量:
// Store first result set
if ($result=mysqli_store_result($con))
{
$r = array();
while($row = mysqli_fetch_array($result))
{
array_push($r,
array('total_wt'=>$row[0],
'pymt_amount'=>$row[0],$row[1],
'mode_of_pymt'=>$row[0],$row[1]));
}
echo json_encode(array("result"=>$r));
输出:
efc90fde-c75c-d5e5-bd3e-7f7ce358e2e2=[{{artifacturl:http://10.1.18.12:8088/job/Xyz/640/artifact/target/xyz.war}}
期待:
efc90fde-c75c-d5e5-bd3e-7f7ce358e2e2=[{artifacturl:http://10.1.18.12:8088/job/Xyz/640/artifact/target/xyz.war}
答案 0 :(得分:0)
只是做:
$package = $package+$component+"=[{"+$componentField+":"+$componentValue+"}".Replace("{{", "{")..Replace("}}", "}")
顺便说一句,这应该也可以解决问题:
$package = $package+$component+ "=[$componentField:$componentValue"
答案 1 :(得分:0)
您还可以使用正则表达式替换字符串:
$package -replace '({|})\1', '$1'
但是,我建议你使用格式字符串构建字符串:
$package = '{0}{1}=[{2}:{3}' -f $package, $component, $componentField, $componentValue