如何将变量插入正在创建的新变量中?我将之前创建的$ array [0]插入$ txt。我该怎么办?
问候
$conn = new mysqli("localhost","user","pass","db");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sets = "SELECT grp_phone FROM groups WHERE grp_onoff='YES'ORDER BY id ASC";
if ($result = mysqli_query($conn,$sets)){
$array = array();
while($r = mysqli_fetch_array($result))
$array[] = $r[0];
}
$group = fopen("/tmp/group_70000.txt", "w+") or die("Unable to open file!");
$txt = 'SET Station_Group "1": "1": "70000"
{
Attached_Stations = {".$array[0]"}
}';
fwrite($group, $txt);
fclose($group);
$conn->close();```
随着{" '.$array[0] .' "}
您得到您想要的价值。看一看
<?php
$array[0] = "100";//example
$txt = 'SET Station_Group "1": "1": "70000"
{
Attached_Stations = {" '.$array[0] .' "}
}';
echo $txt;
你得到
SET Station_Group "1": "1": "70000"
{
Attached_Stations = {" 100 "}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句