我想从此输出获取id并更新数据库我如何从此查询中获取?
$text = "<test>output: 1;outdoor: 456;<test>
<test>output: 2;outdoor: 4564;<test>
<test>output: 3;outdoor: 645;<test>
<test>output: 4;outdoor: 765;<test>";
mysql_query("UPDATE test SET outdoor = $outdoor" where id = $output);
答案 0 :(得分:0)
请尝试我的回答
<?php
$text = "<test>output: 1;outdoor: 456;<test>
<test>output: 2;outdoor: 4564;<test>
<test>output: 3;outdoor: 645;<test>
<test>output: 4;outdoor: 765;<test>";
$text_arr = explode("\n",$text);
foreach($text_arr as $val_text_arr){
/*echo $val_text_arr."<bR>";*/
$output = explode(";",explode("output: ",$val_text_arr)[1])[0];
echo "output ".$output ."\n";
$outdoor = explode(";",explode("outdoor: ",$val_text_arr)[1])[0];
echo "outdoor ".$outdoor ."\n";
/*you can update here ypur query*/
mysql_query("UPDATE test SET outdoor = $outdoor" where id = $output);
}
?>
输出:
output 1
outdoor 456
output 2
outdoor 4564
output 3
outdoor 645
output 4
outdoor 765
php链接我试试这个 https://eval.in/872778