如何匹配来自foreach循环的两个相同的单词

时间:2016-06-12 15:35:20

标签: php

我必须在数据库中存储一些数据。

Database Table: 
[id] - [name]     - [detail]
[1 ] - [site_url] - [http://localhost.com]
[2 ] - [home_url] = [http://localhost.com]

我正在使用此代码进行预览。

$options = get_data($conn);
  if(!empty($options)){
      foreach ($options as $Option) {
        $id = $Option['option_id'];
        $name = $Option['option_name'];
        $detial = $Option['option_detail'];
          // here i want to match option detail if site_url or home_url is same 
          // so include('homepage.php');
          else
          header('location: '.$detail) // go to home_url
      }
      } 

我已经在$ detial = $ Option ['option_detail'];

之后在foreach循环中尝试了这段代码
if($name == 'site_url'){
 $site_url = $detail;
}
if($name == 'home_url'){
 $home_url = $detail;
}
if($site_url == $home_url){
  include('home.php'){
  exit();
  }else{
  header('location: '.$home_url);
  exit();
  }
}

0 个答案:

没有答案