变量in然后检查图像是否存在

时间:2015-03-13 20:37:14

标签: php string variables

我有一个变量:

$map = $row['map'];

我需要检查链接是否包含“/ csgo / maps / $ bgimg”。

我试过了:

 $bgimg = 'map/csgo/' . $map. '.jpg';

 if(!file_exists($bgimg)){ $bgimg = "other_link"; }

但是,脚本每次都返回“other_link”。

编辑:

  $topmaps = mysql_query ("SELECT * FROM `lgsl` where status='1' and map!='-' group by map order by count(map) desc limit 0,5");

    if ( $topmaps == true ){
    while ($row = mysql_fetch_array($topmaps))
    {
    $maps = mysql_query("SELECT * FROM `lgsl` where status='1' and `map`='$row[map]'");
    $maps_num = mysql_num_rows($maps);
    if ($maps_num == 1) {$nums = "server";} else {$nums = "servers";}

     $harta = $row['map'];

// CHECK IF BACKGROUND IMAGE EXISTS, IF NOT USE DEFAULT

    $bgimg = 'http://image.www.gametracker.com/images/maps/160x120/csgo/' . $harta . '.jpg';

     if (!file_exists($bgimg)) {
     $bgimg = "http://image.www.gametracker.com/images/maps/160x120/nomap.jpg";
     }

这是我的整个脚本......最后我有一个var_dump($ bgimg),它产生:

 string(62) "http://image.www.gametracker.com/images/maps/160x120/nomap.jpg" - x5 times

0 个答案:

没有答案