gpt4 book ai didi

php - PHP 函数 fwrite 中的 IF THEN 表达式

转载 作者:行者123 更新时间:2023-12-02 08:48:16 25 4
gpt4 key购买 nike

如何将 IF THEN 表达式放入 PHP 函数 fwrite 中?下面给出的代码不能正常工作。请查看行 fwrite($fh, "$row[0]...)

    $myFile = "testFile.php";
$fh = fopen($myFile, 'w') or die("can't open file");

fwrite($fh, "lat lon title description iconOffset icon\n");
foreach ($result4 as $row):
fwrite($fh, "$row[0] $row[1] $row[2] Resource average speed is: $row[3] km/h -10,-10 if($row[4]==0) images/markerRed.png else images/markerGreen.png\n");
endforeach;

fclose($fh);
?>

最佳答案

$image = ($row[4] == 0) ? "images/markerRed.png" : "images/markerGreen.png";
/* ... $row[3] ... ".$image."\n"; */

关于php - PHP 函数 fwrite 中的 IF THEN 表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10703105/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com