我想将多个字符串与条件
连接我正在用ajax和php执行loadmore,我想动态响应,所以我尝试了以下代码
$newList .= '<ul>';
$newList .= '<li>';
$newList .= '<i class="fa fa-calendar"></i>';
$newList .= $this->Common_model->startend_date_format($getEvent['event_stat'], $getEvent['event_end']);
$newList .= '</li>';
$newList .= '<li>';
$newList .= '<i class="fa fa-map-marked"></i>';
if ($city != "") {
$newList .= '<a href=' . base_url() . 'city/' . $this->Common_model->makeSeoUrl($city) . '>' . ucfirst($city) . '</a>, ' ;
}
if ($state != "") {
$newList .= '<a href="' . base_url() . 'state/' . $this->Common_model->makeSeoUrl($state) . '>' . ucfirst($state) . '</a>,  ';
}
if ($get_country_name != "") {
$newList .= '<a href=' . base_url() . 'country/' . $this->Common_model->makeSeoUrl($get_country_name) . '/' . base64_encode($get_country_id) . '>' . ucfirst($get_country_name) . '</a>';
}
$newList .= '</li>';
$newList .= '<li>';
$newList .= '<i class="fa fa-tags"></i>';
$newList .= '<a href=' . base_url() . 'categories' . '#' . $cat_name_event . '>' . $cat_name_event . '</a>';
$newList .= '</li>';
$newList .= '</ul>';
它显示类似
但是实际结果应该是